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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1657 views
  • 2 likes
  • 3 in conversation