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.);
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: