In the Data step, Can some one help me how could I exclude some of observations whose procedure codes are between 50000 and 59999 OR CPT_REV_CODE 1000 and 1999.
Here is what I’m trying to do:
DATA WANT;
SET TESTING;
IF PROCEDURE_CODE BETWEEN '50000' and '59999'
or CPT_REVENUE_CODE between '1000' and '1999' THEN DELETE;
RUN;
Hi,
Hoping that both the columns are numeric then you may follow the below code
data want;
set testing;
if (50000<=PROCEDURE_CODE<=59999) or (1000<=CPT_REVENUE_CODE<=1999) then delete;
run;
Please do let me know if this worked.
Thanks,
Jag
Hi,
Hoping that both the columns are numeric then you may follow the below code
data want;
set testing;
if (50000<=PROCEDURE_CODE<=59999) or (1000<=CPT_REVENUE_CODE<=1999) then delete;
run;
Please do let me know if this worked.
Thanks,
Jag
Thanks Jagadishkatam and It worked.
You could also use a WHERE clause. If large volumes are involved it may be more efficient to use a format for testing. Create separate formats if ranges overlap.
Proc format ;
value testfmt
1000 - 1999 = 'X'
50000 - 59999 = 'Z'
OTHER = 'O'
;
Quit ;
data want;
set testing;
where not (put(PROCEDURE_CODE, testfmt.) = 'Z'
or (put(CPT_REVENUE_CODE, testfmt.) = 'X'
)
;
run;
Richard
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 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.
Ready to level-up your skills? Choose your own adventure.