BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
RandyStan
Fluorite | Level 6

Dear All:

  I am trying a IF/THEN statement and I do not seem to get the syntax.

  The conditions are as follows

 

  If Year < 2015 and 

 date not between 24SEP2014 and 08OCT2014 and 

  Group_ID >15 then

  Group_ID = 14

 

Data want ; set have ;

if Year <2015 and date NE (24SEP2014 le 08OCT2014) and Group_ID > 15 then do; 

Group_ID = 14;

run;

I do not seem to get the date statement correctly.

 

Please help.

  Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Your date comparisons are incorrect.

 

Data want ; 

set have ;

if Year <2015 
    and not ( '24Sep2014'd <= date <= '08Oct2014'd) 
    and Group_ID > 15 
              then Group_ID = 14;

run;

 


@RandyStan wrote:

Dear All:

  I am trying a IF/THEN statement and I do not seem to get the syntax.

  The conditions are as follows

 

  If Year < 2015 and 

 date not between 24SEP2014 and 08OCT2014 and 

  Group_ID >15 then

  Group_ID = 14

 

Data want ; set have ;

if Year <2015 and date NE (24SEP2014 le 08OCT2014) and Group_ID > 15 then do; 

Group_ID = 14;

run;

I do not seem to get the date statement correctly.

 

Please help.

  Thanks in advance


 

View solution in original post

1 REPLY 1
Reeza
Super User

Your date comparisons are incorrect.

 

Data want ; 

set have ;

if Year <2015 
    and not ( '24Sep2014'd <= date <= '08Oct2014'd) 
    and Group_ID > 15 
              then Group_ID = 14;

run;

 


@RandyStan wrote:

Dear All:

  I am trying a IF/THEN statement and I do not seem to get the syntax.

  The conditions are as follows

 

  If Year < 2015 and 

 date not between 24SEP2014 and 08OCT2014 and 

  Group_ID >15 then

  Group_ID = 14

 

Data want ; set have ;

if Year <2015 and date NE (24SEP2014 le 08OCT2014) and Group_ID > 15 then do; 

Group_ID = 14;

run;

I do not seem to get the date statement correctly.

 

Please help.

  Thanks in advance


 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 224 views
  • 0 likes
  • 2 in conversation