Hi, I am very new to SAS, so I'm still learning...
How do create a new data set and select non-zero values in a column?
Thank you.
Let's assume the existing dataset is named HAVE and the variable you want to test is named STATUS.
Then to make a new dataset, let's call it WANT, that is the subset of HAVE that has non zero values of STATUS you could use this simple data step.
data want;
set have;
where status ne 0 ;
run;
Let's assume the existing dataset is named HAVE and the variable you want to test is named STATUS.
Then to make a new dataset, let's call it WANT, that is the subset of HAVE that has non zero values of STATUS you could use this simple data step.
data want;
set have;
where status ne 0 ;
run;
A slight variation on that result:
data want;
set have;
where status;
run;
This removes cases that have zero for STATUS, and also removes cases that have a missing value for STATUS. Which one you use depends on which result you want.
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.