BookmarkSubscribeRSS Feed
mandyosu01
Obsidian | Level 7

Hello SAS support community,

 

I am working on the following code but keep having errors on the THIRD PART while the first two parts are fine. Thank you so much in advance!

 

 

proc sort data=lag   out=temp2;
by key fyear dummy lagdummy;
run;


data test2;
set temp2;
by dummy notsorted;
if last.dummy;
count = _n_ - sum(lag(_n_), 0);
do _n_ = 1 to count;
set temp2;
output;
end;
run;

 

 

data final2;
set test2;
by key ;
if
lagdummy - dummy =1  then do

if (dummy = 0 and count > 2) or   ( dummy= 1 and count > 3) then output;

end;
run;

1 REPLY 1
Shmuel
Garnet | Level 18

You miss a semicolon after do:

lagdummy - dummy =1  then do ;

if (dummy = 0 and count > 2) or   ( dummy= 1 and count > 3) then output;

end;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 417 views
  • 1 like
  • 2 in conversation