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

I have a large claims dataset that I flagged for variables of interest but now I want to identify those with no flagged variables,

I flagged these variables by writing a code like this

 

data want;

set have;

if  ndc=123 then a=1;

else if ndc=456 then b=1;

else if ndc=789 then c=1;

run;

 

What I have now is

ID  A   B  C

1   1

2

3        1

4

5              1

 

Then I want to flag ID 2 and 5 for not having any flagged variables

I tried

data want;

set have;

where a ne 1 and b ne 1 and c ne;

run;

The above code did not flag ID 2 and 5

 

Please help

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

By any chance, did you actually complete the WHERE statement?  It looks like it's missing the number '1' at the end.

 

Another possibility to consider:  You are using the data set HAVE as input to both DATA steps.  But HAVE doesn't contain A, B, and C.  You need to use the output from the first DATA step as the input to the second DATA step.

 

Finally, you may find this easier to read:

 

where sum(0, a, b, c) = 0;

View solution in original post

2 REPLIES 2
Astounding
PROC Star

By any chance, did you actually complete the WHERE statement?  It looks like it's missing the number '1' at the end.

 

Another possibility to consider:  You are using the data set HAVE as input to both DATA steps.  But HAVE doesn't contain A, B, and C.  You need to use the output from the first DATA step as the input to the second DATA step.

 

Finally, you may find this easier to read:

 

where sum(0, a, b, c) = 0;

Reeza
Super User

Try the N or NMISS functions

 

if n(a, b, c) < 1 then ..... ;

 


@leahcho wrote:

I have a large claims dataset that I flagged for variables of interest but now I want to identify those with no flagged variables,

I flagged these variables by writing a code like this

 

data want;

set have;

if  ndc=123 then a=1;

else if ndc=456 then b=1;

else if ndc=789 then c=1;

run;

 

What I have now is

ID  A   B  C

1   1

2

3        1

4

5              1

 

Then I want to flag ID 2 and 5 for not having any flagged variables

I tried

data want;

set have;

where a ne 1 and b ne 1 and c ne;

run;

The above code did not flag ID 2 and 5

 

Please help

Thanks


 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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