BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

Hello,

 

Does someone know how many significant digits do we have using a PD.6 format.

Could it be possible to get a table showing the number of significant digits for each PD.x format.

 

Regards,

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

I ran this test:

data test;
length checkvar $12;
input number;
checkvar = put(put(number,pd6.),$hex12.);
datalines;
123456789
-123456789
1234567890
-1234567890
12345678901
123456789012
1234567890123
;

proc print data=test;
run;

and got this result:

Beob.      checkvar             number

  1      000123456789        123456789
  2      800123456789       -123456789
  3      001234567890       1234567890
  4      801234567890      -1234567890
  5      009999999999      12345678901
  6      009999999999     123456789012
  7      009999999999    1234567890123

So it can be seen that a full byte is reserved for the (possible) sign. This behavior is described in the OS-specific documentation of the PD format:

UNIX 

Windows 

View solution in original post

6 REPLIES 6
ballardw
Super User

Digits or significant digits? Not the same thing. The significant digits are use specific.

 

The W is the number of BYTES in the output, and each byte has two digits. So PD6. = 12 digits.

 

 

alepage
Barite | Level 11
Thank you very much for the precision.



So it means that if we use a PD6 format , we can have any number between 0 and 999  999 999 999.

What will happen if the number is bigger then 999  999 999 999? 


Regards,
alepage
Barite | Level 11
I though that PD6 could take 12 digits. It is not the case?

/*11 digits*/
data test;
length checkvar $12;
checkvar = put(put(12345671234,pd6.),$hex12.);

/*10 digits*/

length checkvar1 $12;
checkvar1 = put(put(1234567899,pd6.),$hex12.);
run;
ballardw
Super User

You are not starting with a packed decimal value.

Kurt_Bremser
Super User

I ran this test:

data test;
length checkvar $12;
input number;
checkvar = put(put(number,pd6.),$hex12.);
datalines;
123456789
-123456789
1234567890
-1234567890
12345678901
123456789012
1234567890123
;

proc print data=test;
run;

and got this result:

Beob.      checkvar             number

  1      000123456789        123456789
  2      800123456789       -123456789
  3      001234567890       1234567890
  4      801234567890      -1234567890
  5      009999999999      12345678901
  6      009999999999     123456789012
  7      009999999999    1234567890123

So it can be seen that a full byte is reserved for the (possible) sign. This behavior is described in the OS-specific documentation of the PD format:

UNIX 

Windows 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1223 views
  • 1 like
  • 3 in conversation