BookmarkSubscribeRSS Feed
jaiganesh
Obsidian | Level 7

Hello,

 

 

SAS internal Date format for 5/1/2019 is 43586.

 

Could anybody suggest, How to convert 43586 back to 5/1/2019 after importing ?

 

 

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Simply apply an appropriate format. However, I fail to see how 43586 in any format can be 5/1/2019? 🙂

 

data test;
   date=43586;
   format date mmddyy10.;
run;
tsap
Pyrite | Level 9

Can you please provide some additional details/logic regarding the importing of this data? This is so that we can have a better understanding of what is taking place, which in turn will allow us to provide a better answer to your question.

 

Thanks

FreelanceReinh
Jade | Level 19

@jaiganesh wrote:

SAS internal Date format for 5/1/2019 is 43586.

Nope. This looks much more like an Excel date (i.e. number of days after 31 Dec 1899, but including the non-existent 29 Feb 1900 -- known bug in Excel -- hence the 43585 below):

%put %sysevalf('01MAY2019'd-'31DEC1899'd); /* result: 43585 */

So, you'd need to subtract the "magic" number 21916 (=Excel date for SAS date 0, i.e. '01JAN1960'd) to arrive at a SAS date value, e.g., 21670 for 1 May 2019. (Search for "21916" in this forum and you'll find related discussions, e.g., this: https://communities.sas.com/t5/SAS-Programming/IF-THEN-ELSE-for-date-format-check/td-p/298030)

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
  • 3 replies
  • 1165 views
  • 1 like
  • 4 in conversation