BookmarkSubscribeRSS Feed
SSK_011523
Calcite | Level 5

Hello, 

Thank you for this community so far. It is of being great help!

 

In my project, comorbidities are identified using ICD-10 diagnosis codes where there is ≥ 1 inpatient or ≥ 2 outpatient claims (on different dates) during the 12-month baseline period. 

 

I have trouble coding for at least two outpatient claims from medical file. I used the following code but the sample size decreased drastically so I am not sure if I am doing it right.

 

Data test;

  input patid $ comorb_date YYMMDD10 diag$;

cards;

      1    2019/01/23 AZER

      1   2019/01/23 AZER

      1   2021/04/04 TRE

      2   2018/08/09 TYR

     2    2018/08/09   QWK

run;

   Data want will look like this - 

   

       1    2019/01/23 AZER

      1   2021/04/04 TRE

      2   2018/08/09 TYR

      2    2018/08/09   QWK

 

Patid 1 had same diag codes on 2019/01/23 so one row was removed. Patid 2 has different diagnosis codes on the same date so it will be retained.

 

Tried code - 

 

Proc sql;
create table OP_twodiagnosis as
select patid, count (distinct comorb_date) as cnt_op_dx
from test
group by patid, diag
;
quit; 

Data created.OP_twodiagnosis_2;
set created.OP_twodiagnosis;
if cnt_op_dx >= 2;
run; 

 

Best, 

Shweta

2 REPLIES 2
ballardw
Super User

First please test example data step code. Your code doesn't use YYMMDD10 as the  informat as it is missing the period at the end. Also Cards or datalines end with a ; .

 

It is a good idea on this forum to paste data step (and other code as well) into a text box opened on the forum with the </> icon to prevent the forum software from reformatting text pasted into the main message windows. With data step that reformatting can change column positions enough that some input statements throw errors or read values incorrectly or sometimes acquire not visible characters that will cause other problems.

 

You didn't provide much example data and completely skipped over how to tell the difference between an inpatient and outpatient observation. This might provide some help as a starting point for next steps using that information.

 

SQL is pretty weak about anything regarding order of processing and you have an explicit order requirement (not two or more same diad on a date per patient) and possibly implied in the inpatiend/outpatient bit since different counts are used for a rule.

proc sort data=test out=testless nodupkey;
   by patid comorb_date diag;
run;

/* add a diag counter*/
data helpful;
   set testless;
   by patid comorb_date;
   retain counter;
   if first.patid then counter=1;
   else counter+1;
run;

I added a counter variable so you can see the way things increment.

mkeintz
PROC Star

Questions:

  1. If a patient has one inpatient claim and one outpatient claim, do you keep both records for that patient?  Or just the qualifying record?
  2. How do you identify inpatient vs outpatient claims?
  3. Do any of your patients have data spanning more than twelve months?
    1. If a patient has two years of data, and two qualifying records in the first twelve months, do you keep the entire history?
    2. Or maybe only records within twelve months of the nearest qualifying records?
  4. Are your data sorted, as in your example?
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 365 views
  • 0 likes
  • 3 in conversation