BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
lolol0101
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

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;

 

Astounding
PROC Star

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2403 views
  • 1 like
  • 3 in conversation