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
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.