BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AliMN
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

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,
Jag

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

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,
Jag
AliMN
Calcite | Level 5

Thanks Jagadishkatam and It worked.

RichardinOz
Quartz | Level 8

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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 802 views
  • 0 likes
  • 3 in conversation