View previous topic :: View next topic
|
Author |
Message |
vigneshkru
New User
Joined: 30 Jul 2009 Posts: 2 Location: Chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hi,
I think the code must be
Code: |
ENTITYAN = PUT(ENTITY,5.) ; |
without $ ?
Syntax:
INPUT(source,informat)
PUT(source,format)
Hope this helps
Thanks & Regards, |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Code: |
ENTITYAN = PUT(ENTITY,$5.) ; |
AND
Code: |
ENTITYAN = PUT(ENTITY,5.) ; |
both work. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
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.
is correct.
Robert,
Please correct me if I am wrong.
Thanks & Regards, |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
vigneshkru
New User
Joined: 30 Jul 2009 Posts: 2 Location: Chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|