Hi I need help in extracting only policies whereby there is a value greater than or equals 1 from either contents/ motor/ home columns..if all the values from contents/ motor/ home columns are 0, then delete the entire row..
see below code for data have
data have;
input policy_no risk contents motor home cycle;
datalines;
1 1 0 1 0 0
2 0 0 0 0 1
3 0 1 1 2 1
4 1 0 0 0 0
5 1 0 0 0 1
6 0 1 1 2 0
;
Data Want
policy_no risk contents motor home cycle
1 1 0 1 0 0
3 0 1 1 2 1
6 0 1 1 2 0
Do this
data have;
input policy_no risk contents motor home cycle;
datalines;
1 1 0 1 0 0
2 0 0 0 0 1
3 0 1 1 2 1
4 1 0 0 0 0
5 1 0 0 0 1
6 0 1 1 2 0
;
data want;
set have;
if sum(contents, motor, home);
run;
Result:
policy_no risk contents motor home cycle 1 1 0 1 0 0 3 0 1 1 2 1 6 0 1 1 2 0
Do this
data have;
input policy_no risk contents motor home cycle;
datalines;
1 1 0 1 0 0
2 0 0 0 0 1
3 0 1 1 2 1
4 1 0 0 0 0
5 1 0 0 0 1
6 0 1 1 2 0
;
data want;
set have;
if sum(contents, motor, home);
run;
Result:
policy_no risk contents motor home cycle 1 1 0 1 0 0 3 0 1 1 2 1 6 0 1 1 2 0
Anytime 🙂
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.