Hi,
Example input data:
Pat_ID Pay_code
A1 1001
A2 1002
A3 1003
A3 4549
A4 5567
A5 1001
A6
A7 XXXX
I need to only keep the entries say with pay_code being 1001, 1002, 1003 and 5567. I tried to use this but it doesn't seem to work.
data pat_pay;
set pay_info;
if pay_code EQ '1001' or '1002' or '1003' or '5567';
run;
Hi,
Replace the if with a Where, or use a then output:
data pat_pay;
set pay_info;
where pay_code in ('1001','1002');
run;
You can also put it on the set statement for some performance gain:
data pat_pay;
set pay_info (where=(pay_code in ('1001','1002')));
run;
Hi,
Replace the if with a Where, or use a then output:
data pat_pay;
set pay_info;
where pay_code in ('1001','1002');
run;
You can also put it on the set statement for some performance gain:
data pat_pay;
set pay_info (where=(pay_code in ('1001','1002')));
run;
Hi,
Thanks! I was wondernig how to output the observations with the rate codes wanted to one dataset and the remaining to another one using where in?
The EQ operator can compare a value with a single value. The IN operator checks the current variable for a list of values, please use RW9 's solution.
I agree with RW9: using where instead of If when possible is better.
Anyway, the correct syntax of the if statement would be:
if pay_code EQ '1001' or pay_code EQ '1002' or pay_code EQ '1003' or pay_code EQ '5567';
CTorres
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!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.