BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sks521
Quartz | Level 8

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Your date constant is not right.

'20160901'd

-->

'01sep2016'd

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
sks521
Quartz | Level 8

Fabulous! it worked

 

Thanks

Ksharp
Super User

Your date constant is not right.

'20160901'd

-->

'01sep2016'd

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
  • 2322 views
  • 2 likes
  • 3 in conversation