BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
monsterpie
Obsidian | Level 7

Hi all, 

I have a dataset with 100 binary variables (var1 - var100). I am trying to delete observations that meet the following criteria: were coded as 1 for var1 AND were coded as 0 across all other variables (var2-var100). I.e., if an observation was coded as 1 for var1 and for var2 it would NOT be deleted. if it was coded as 1 for var1 and 0 for all other variables, it would be deleted. 

 

The following is the code I have tried thus far:

 

data winterd.wintert4B;
set winterd.winter_t4;
if var1=1 and (var2--var100)=0 then delete;
run;

Also please note, my variables are not actually sequentially named/ordered, "var1-100" is just for the purposes of this post. 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Try this:

data winterd.wintert4B;
set winterd.winter_t4;
if var1=1 and sum(of var2-var100)=0 then delete;
run;

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

Try this:

data winterd.wintert4B;
set winterd.winter_t4;
if var1=1 and sum(of var2-var100)=0 then delete;
run;
monsterpie
Obsidian | Level 7
Thank you!!

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