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


 

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

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

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1145 views
  • 0 likes
  • 2 in conversation