Excluding part of data/observations

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

Excluding part of data/observations

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;


Accepted Solutions
Solution
‎01-15-2013 10:00 AM
Trusted Advisor
Posts: 1,137

Re: Excluding part of data/observations

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


All Replies
Solution
‎01-15-2013 10:00 AM
Trusted Advisor
Posts: 1,137

Re: Excluding part of data/observations

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
Contributor
Posts: 49

Re: Excluding part of data/observations

Posted in reply to Jagadishkatam

Thanks Jagadishkatam and It worked.

Super Contributor
Posts: 644

Re: Excluding part of data/observations

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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