BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mayasak
Quartz | Level 8

I'm trying to get a subset dataset which contains variables uns_n and sns_n ne '.' and uns_n and sns_n ne 0 and drug = 'abc'.

Here's the code I had:

data ABgn;
set ABgn_Miss (where=(drug='abc') and uns_n ne . & uns_n ne 0 & sns_n ne . & sns_n ne 0 );
run;

I also tried different ways but I'm not getting the right data set needed. 

I'm wondering what is the best way to do it.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

A useful shortcut:

set ABgn_Miss (where=(drug='abc' and uns_n and sns_n));

Numeric values of missing and zero are considered to be false while all other values are considered to be true.

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

Try this - it looks like your brackets aren't quite right.

data ABgn;
set ABgn_Miss (where=(drug='abc' and uns_n not in (.,0) and sns_n not in (.,0));
run;
Astounding
PROC Star

A useful shortcut:

set ABgn_Miss (where=(drug='abc' and uns_n and sns_n));

Numeric values of missing and zero are considered to be false while all other values are considered to be true.

mayasak
Quartz | Level 8
Thank you. That was helpful

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 545 views
  • 3 likes
  • 3 in conversation