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.
Try this:
data winterd.wintert4B;
set winterd.winter_t4;
if var1=1 and sum(of var2-var100)=0 then delete;
run;
Try this:
data winterd.wintert4B;
set winterd.winter_t4;
if var1=1 and sum(of var2-var100)=0 then delete;
run;
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: