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

I am currently attempting to use a number of different definitions to identify cancer cases in claims data.  In this definition, I would like to require that TWO OR MORE of the diagnosis fields (dx1 - dx15) be related to cancer. 

I have been using a simple array to identify when ONE OR MORE of the dx fields were related to cancer:

ARRAY surgINdx(15) $ dx1-dx15;

  DO r=1 to 15;

  IF surgINdx(r) IN("162%" "2312%")

  THEN rDX=1;

  ELSE rDX = 0;

END;

RUN;

My question is this: how can I command my output variable rDX to be a count of the number of dx fields that were cancer related, rather than identifying if any of them were cancer related?

I was hoping to use the code below but for some reason, everybody ends up with rDX = 0.  I figured I'd preset all rDX to 0, then add 1 each time that dx1 through dx15 is a cancer related code.  Can somebody point out to me what is wrong?  The log looks good.  No errors or anything.

  *INPATIENT*;

DATA hw3.lungSURGin;

  SET all_inclaims;

  rDX=0;

  ARRAY surgINdx(15) $ dx1-dx15;

  DO r=1 to 15;

  IF surgINdx(r) IN("162%" "2312%")

  THEN rDX+1;

  ELSE rDX+0;

  END;

  RUN;

*REGARDLESS OF WHETHER I USE PROC SQL OR PROC PRINT, THERE ARE NO OBSERVATIONS WHERE rDX > 1*;

PROC SQL;

select count(distinct enrolid) as cases_surgIN

from hw3.lungSURGin

WHERE rdx > 1;

QUIT;

RUN;

PROC PRINT DATA=hw3.lungSURGin (OBS=100);

WHERE rDX>1;

RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

First your IF condition looks wrong.  Are you thinking that the percent sign is going to be treated like a wildcard?

Perhaps you want to use the : modifier on the IN operator instead.  This will allow DX codes like '1621' to match.

rdx=0;

array surgindx dx1-dx15;

do r=1 to dim(surgindx);

  if surgindx(r) in: ('162' '2312') then rdx+1;

end;

View solution in original post

3 REPLIES 3
mconover
Quartz | Level 8

My numbers are really low.  I'm starting to wonder if the coding is actually right and there are just no cases that meet my definition...

Tom
Super User Tom
Super User

First your IF condition looks wrong.  Are you thinking that the percent sign is going to be treated like a wildcard?

Perhaps you want to use the : modifier on the IN operator instead.  This will allow DX codes like '1621' to match.

rdx=0;

array surgindx dx1-dx15;

do r=1 to dim(surgindx);

  if surgindx(r) in: ('162' '2312') then rdx+1;

end;

ZachLain
Calcite | Level 5

mconover, I also work in the health care industry (health insurance) and frequently have to run reports populated by summarized data similar to what you are trying to do here. However, I only use Enterprise Guide and the query builder tool as I am not yet very familiar with the SAS code syntax (I am a programmer at heart but haven't learned the SAS ropes yet).

I think that the code Tom posted should work just fine, but if you are interested in building this utilizing the EG query builder consider using a case statement to populated a calculated column:

CASE WHEN t1.surgindx LIKE '162' OR LIKE '2312' THEN 1

           ELSE 0

END

Once you create this calculated column drag it into the selected column area in the query builder and SUM the field. The output should be a count of every claim that is related to cancer. If you do not sum the calculated column then the output will just be a list of flags (also useful sometimes depending on your situation).

I hope this helps!

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1981 views
  • 0 likes
  • 3 in conversation