Hello,
I have two datasets. In the first one, the var date1 as the date format 23dec2020 while in the other dataset, the date2 as the following date format : 2020-12-23 (yyyy-mm-dd).
How can I bring back both to numerical value ex; 22272 in order to compare both dataset.
Regards,
Date2 is not a SAS date value, nor is it formatted as YYYY-MM-DD.
Date2 is 2020 minus 12 minus 23, which is ... well you do the math.
If you want Date 2 to be a SAS date value, you should use this:
date2=input('2020-12-23',yymmdd10.);
According to PROC CONTENTS, is date1 character or numeric? According to PROC CONTENTS, is date2 character or numeric?
For numeric variables, format doesn't matter when you compare variables.
if date1<date2 then ... ;
works regardless of format. Formats just change the appearance, they don't affect the actual date values.
Date2 is not a SAS date value, nor is it formatted as YYYY-MM-DD.
Date2 is 2020 minus 12 minus 23, which is ... well you do the math.
If you want Date 2 to be a SAS date value, you should use this:
date2=input('2020-12-23',yymmdd10.);
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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.