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

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
  • 3 replies
  • 938 views
  • 3 likes
  • 3 in conversation