BookmarkSubscribeRSS Feed
blackandwhite
Obsidian | Level 7

Hello, I am looking to delete all initial observations of VAR, within each ID group, until we hit the first 0. If none of the values within an ID group are 0, then I want to remove all of them.

 

Here is a example of the data I have. I would like to remove observations 1, 10, 11, 12, 13 and 14

 

Thanks in advance!

observationIDVAR
111
210
311
410
511
611
720
821
920
1031
1131
1231
1341
1441
1540
1641
2 REPLIES 2
Haikuo
Onyx | Level 15
data want;
do until (last.var);
set have;
by id var notsorted ;
if first.id and var=1 then flag=1;
if flag ne 1 then output ;
end;
run;

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
  • 2 replies
  • 3268 views
  • 1 like
  • 3 in conversation