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
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;
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;
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
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.
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.