BookmarkSubscribeRSS Feed
MichielBorkent
Calcite | Level 5
Can someone explain where the highest precision numbers in variables d4 to d7 came from?

The SAS program:

data foo;
format d1-d7 datetime30.6;
timestring = "23:59:59.997000000";
time = input(timestring,time18.);
d1 = dhms(0,0,0,time);
d2 = dhms('08DEC1981'd,0,0,time);
d3 = dhms('31DEC2503'd,0,0,time);
d4 = dhms('31DEC2504'd,0,0,time);
d5 = dhms('08DEC2981'd,0,0,time);
d6 = dhms('08DEC4981'd,0,0,time);
d7 = dhms('08DEC9999'd,0,0,time);
run;
proc print;run;

The output:

Obs d1 d2 d3

1 01JAN1960:23:59:59.997000 08DEC1981:23:59:59.997000 31DEC2503:23:59:59.997000

Obs d4 d5 d6

1 31DEC2504:23:59:59.997002 08DEC2981:23:59:59.997002 08DEC4981:23:59:59.996994

Obs d7 timestring time

1 08DEC9999:23:59:59.997009 23:59:59.997000000 86400.00
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You can do this by using the BEST. format -- also, the LENGTH statement has influence on granularity, as where the FORMAT statement influences the output format being displayed. As well, the higher the date, the larger integer portion of the SAS variable occurs. Also, the SAS OS platform has some influence. Suggested links for reading provided below.

Scott Barry
SBBWorks, Inc.


SAS 9.2 Language Reference: Concepts - Numeric Precision in SAS Software:
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000695157.htm

SAS 9.2 Language Reference: Concepts - About SAS Date, Time, and Datetime Values
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a002200738.htm


Step-by-Step Programming with Base SAS(R) Software - Working with Numeric Variables:
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304311.htm

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1060 views
  • 0 likes
  • 2 in conversation