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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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