Hi,
I am trying to create a dummy variable as follows;
before 1st September 2016 as pre-intervention;
from 01/09/2016 to 28/02/2017 as intervention
After 28/02/2017 as post-intervention
If I run proc contents, the log says its in 'yymmdd10' format;
in proc print output log the dates look like for e.g.;
2018-06-18.
When I write the following syntax;
data dummy;
set combined;
format EventDate YYMMDD10.;
if EventDate<'20160901'd then group=0;*intervention;
else if '20160901'd =<EventDate>= '20170228'd then group=1;*pre-intervention;
else group=2;*post-intervention;
run;
it gives me an error message.
Can someone help please?
Thanks
Shah
@sks521 wrote:
if EventDate<'20160901'd then group=0;*intervention;
The proper syntax here is:
if EventDate<'01SEP2016'd then group=0;
It doesn't matter what the format of the variable is, your date constant must be in the format shown.
Fabulous! it worked
Thanks
Your date constant is not right.
'20160901'd
-->
'01sep2016'd
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.