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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.