View previous topic :: View next topic
|
Author |
Message |
jithumohan
New User
Joined: 31 Jan 2008 Posts: 30 Location: Woodland Hills, CA
|
|
|
|
Can anybody help me to convert a packed decimal variable to an alphanumeric value without zero padding? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
What programming language are you using ? |
|
Back to top |
|
|
jithumohan
New User
Joined: 31 Jan 2008 Posts: 30 Location: Woodland Hills, CA
|
|
|
|
SAS in mainframes |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Then read the data into a variable defining it as PDn.
Zero padding is usually off by default |
|
Back to top |
|
|
jithumohan
New User
Joined: 31 Jan 2008 Posts: 30 Location: Woodland Hills, CA
|
|
|
|
Hi please find the below scenario.
Packed Decimal value in the input file = 003
I want to create a report using this file. But the report conatins only 3. I want the data as 003. Please note that the value in the input file is of Packed decimal 9(03) comp-3. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
jithumohan wrote: |
Can anybody help me to convert a packed decimal variable to an alphanumeric value without zero padding? |
Huh ? - You asked for the value without zero padding, and now you want zero padding ?
Which do you really want
3 or 003 |
|
Back to top |
|
|
jithumohan
New User
Joined: 31 Jan 2008 Posts: 30 Location: Woodland Hills, CA
|
|
|
|
I am sorry for the first query... Actually I want the data with zeros....
Sorry for my mistake. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Then use a format for that variable in the report. |
|
Back to top |
|
|
jithumohan
New User
Joined: 31 Jan 2008 Posts: 30 Location: Woodland Hills, CA
|
|
|
|
I tried a lot. Could you help me with an exact syntax?[/list] |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Ok, I will take a look at what you have tried, please post the code you are using to format the data. |
|
Back to top |
|
|
jithumohan
New User
Joined: 31 Jan 2008 Posts: 30 Location: Woodland Hills, CA
|
|
|
|
Input field
@1 PLAN PD2.0
I used the following code for coverting
SAS_PLAN = PUT(PLAN,3.);
CHR_PLAN = SAS_PLAN;
But the output was only '3'. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
The SAS default is to remove leading zeros, so you need to use a format that will insert the leading zeros.
My style of coding has changed a lot since working with other people, and this is just a hint that I have picked up on, but I usually define formats at the start of the data step, and then know that the data will be in the format I require when it is written out.
Code: |
DATA STEP;
FORMAT VAR1 3.
VAR2 $3.
VAR3 Z3.;
|
|
|
Back to top |
|
|
jithumohan
New User
Joined: 31 Jan 2008 Posts: 30 Location: Woodland Hills, CA
|
|
|
|
Thanks for the help .... I got the solution... |
|
Back to top |
|
|
|