Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 8165
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: 1522
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: 8165
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: 1522
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: 8165
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: 8165
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 How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Accessing CICS tran with map from JCL... navdeepaggarwal CICS 5 Tue Oct 03, 2017 6:15 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us