IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

converting packed decimal to alphanumeric using SAS program


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
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
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Jul 30, 2009 8:37 pm
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: 1742
Location: Tirupur, India

PostPosted: Thu Jul 30, 2009 9:39 pm
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Jul 30, 2009 10:36 pm
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: 1742
Location: Tirupur, India

PostPosted: Fri Jul 31, 2009 2:59 pm
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 31, 2009 5:05 pm
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
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Sun Aug 02, 2009 1:09 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Using API Gateway from CICS program CICS 0
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts DB2 Event passed to the Application P... DB2 1
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
Search our Forums:

Back to Top