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


 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 2 replies
  • 741 views
  • 1 like
  • 3 in conversation