BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
desireatem
Pyrite | Level 9

Thank you but it still does not work, 

new_dt Num 8 E8601DT19.    

Despite it added a T "

1 2021-01-25T07:31:00
Kurt_Bremser
Super User

Don't be silly. Of course it worked, the datetime value was stored in a character string with the desired format. This is proof that you have a real SAS datetime value in MEWSO2_DT with which you can make all datetime-related calculations possible in SAS, without ANY prior conversion.

What do you want to calculate from your datetime values?

desireatem
Pyrite | Level 9

It didn't work, still saying num despite adding "T"   

  new_dt Num 8 E8601DT19.  

 

desireatem
Pyrite | Level 9
Obs P_dta m_dta ORDERS_DTa MEWSO2_DT
1 1924503240 1924506000 1924504020 25DEC20:07:31:00

 

The P_dta, m_dta, orders_dta are SAS data. So you are telling me I can perform subtractions with MEWSSO2_DT despite not in the same presentation?

Tom
Super User Tom
Super User

Numbers are numbers, there is only one way to store a number in SAS, as a binary floating point value.

How you DISPLAY them does not in anyway change the actual number.

666   data test;
667     P_dta = 1924503240;
668     m_dta = 1924506000 ;
669     ORDERS_DTa= 1924504020 ;
670     MEWSO2_DT = '25DEC20:07:31:00'dt;
671     put 'Raw '/ (_all_) (= comma20./)
672       // 'DATETIME ' / (_all_) (= datetime19./)
673    ;
674   run;

Raw
P_dta=1,924,503,240
m_dta=1,924,506,000
ORDERS_DTa=1,924,504,020
MEWSO2_DT=1,924,500,660

DATETIME
P_dta=25DEC2020:08:14:00
m_dta=25DEC2020:09:00:00
ORDERS_DTa=25DEC2020:08:27:00
MEWSO2_DT=25DEC2020:07:31:00
NOTE: The data set WORK.TEST has 1 observations and 4 variables.

A value that is close to 2 billion seconds is going to be pretty close to the current datetime.

659   data test;
660     now=datetime();
661     two_billion = 2E9 ;
662     put (_all_) (= datetime19./)
663      // (_all_) (= comma19./)
664   ;
665   run;

now=09AUG2022:12:30:31
two_billion=18MAY2023:03:33:20

now=1,975,667,431
two_billion=2,000,000,000
NOTE: The data set WORK.TEST has 1 observations and 2 variables.

 

Kurt_Bremser
Super User

SAS datetimes and times are counts of seconds, starting at midnight (for times) or 1960-01-01T00:00:00 (for datetimes). The formats display these values in human-readable form.

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
  • 20 replies
  • 2396 views
  • 0 likes
  • 6 in conversation