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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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