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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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