BookmarkSubscribeRSS Feed
HK1
Calcite | Level 5 HK1
Calcite | Level 5

 

Can you let me know how to read in packed decimal data correctly. I have tried two different formats and it is not listing last digit correctly:

 

 

DATA _NULL_;                         

                                       

  ACCTI = '0123456789001234567C'X;  

  

  ACCTO = INPUT(ACCTI, PD10.);      

  PUT '1 ' ACCTI= HEX. ACCTO= 20.;   

                                

  ACCTO = INPUT(ACCTI,7 S370FPD10.); 

  PUT '2 ' ACCTI= HEX. ACCTO= 20.;   

                                       

RUN;   

The following is the info from SYSOUT

                                                                                         

1 ACCTI=0123456789001234567C ACCTO=123456789001234560

                                                     

2 ACCTI=0123456789001234567C ACCTO=123456789001234560

 

Thanks

4 REPLIES 4
Shmuel
Garnet | Level 18

To read PD you need use informat  S370FPDw.   where w is the length in bytes:

 

6 bytes enable 11 digits and a sign - should be read by: input var s370fpd6.

HK1
Calcite | Level 5 HK1
Calcite | Level 5
Thanks for the info. Here I am trying to read max 18 digits and there is C at the end. Thought in the scenario we will need PD10?
Shmuel
Garnet | Level 18
That's right - s370fpd10.
Kurt_Bremser
Super User

@HK1 wrote:
Thanks for the info. Here I am trying to read max 18 digits and there is C at the end. Thought in the scenario we will need PD10?

Usually, dec_fixed numbers are defined in PL/1 with an uneven number of digits, as you will need 10 bytes for 18 or 19 digits anyway, so the programmer takes the larger digit count.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 982 views
  • 0 likes
  • 3 in conversation