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