Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

converting packed decimal to alphanumeric using SAS program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
vigneshkru

New User


Joined: 30 Jul 2009
Posts: 2
Location: Chennai

PostPosted: Thu Jul 30, 2009 8:15 pm    Post subject: converting packed decimal to alphanumeric using SAS program
Reply with quote

My SAS program takes an input field in PD3(packed decimal) format and gives the output in 5(number format)

eg the input is -- > @25 ENTITY PD3.
output is --> @25 ENTITY 5.

I read that alphanumeric fields need to start with $. So in this case if I just mark the output as ENTITY $5 or is there some more coding that I need to do to covert to alphanumeric?
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jul 30, 2009 8:37 pm    Post subject:
Reply with quote

If you absolutely have to have SAS treat the variable as alphanumeric (for output purposes it doesn't matter -- only if you need the variable within your SAS program to be alphanumeric), you could say
Code:
ENTITYAN = PUT(ENTITY,$5.) ;
to guarantee ENTITYAN is alphanumeric.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1491
Location: Chennai

PostPosted: Thu Jul 30, 2009 9:39 pm    Post subject:
Reply with quote

Hi,

I think the code must be

Code:
ENTITYAN = PUT(ENTITY,5.) ;
without $ ?

Syntax:
INPUT(source,informat)
PUT(source,format)

Hope this helps icon_biggrin.gif

Thanks & Regards,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jul 30, 2009 10:36 pm    Post subject:
Reply with quote

Code:
ENTITYAN = PUT(ENTITY,$5.) ;
AND
Code:
ENTITYAN = PUT(ENTITY,5.) ;
both work.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1491
Location: Chennai

PostPosted: Fri Jul 31, 2009 2:59 pm    Post subject:
Reply with quote

Hi Vignesh,

You are already reading the data in pd3. informat (which is numeric) and this is not a character.

A Put statement will do the trick. PUT fucnction conversion is not required.
Put function is required only for numeric to character conversion.

Code:
PUT @25 ENTITY 5.
is correct.


Robert,

Please correct me if I am wrong.

Thanks & Regards,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Fri Jul 31, 2009 5:05 pm    Post subject:
Reply with quote

Vasanth, I don't know if you're right or wrong -- the o/p hasn't clarified what the requirement is. If the SAS program needs the data as character internally, the PUT function will be the best way to handle the requirement. If all the o/p is doing is wanting to output the data as if it were character, either your PUT statement or the PUT function can be used.
Back to top
View user's profile Send private message
vigneshkru

New User


Joined: 30 Jul 2009
Posts: 2
Location: Chennai

PostPosted: Sat Aug 01, 2009 11:37 pm    Post subject: Reply to: converting packed decimal to alphanumeric using SA
Reply with quote

hey.. thanks for ur help.. to explain the situation more clearly.. i am getting input from a dataset which is giving me input in packed decimal(PD3). output is currently numeric(5).

This is because usually the output is a 5 digit number. However in some cases the data is in alphanumeric format. So when i am fetching the whole list of data these aphanumeric values alone do not show up in the output...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Sun Aug 02, 2009 1:09 am    Post subject:
Reply with quote

In such a case, I would do something like
Code:
INPUT ENTITYAN $3. ;
ENTITY = INPUT(ENTITYAN,PD3.) ;
IF ENTITY = . THEN PUT ENTITYAN $3. ;
              ELSE PUT ENTITY 5. ;
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us