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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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

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
  • 3146 views
  • 1 like
  • 3 in conversation