Help using Base SAS procedures

Readmit Within 7 days - only display first visit but sum all applicable?

Reply
Regular Contributor
Posts: 152

Readmit Within 7 days - only display first visit but sum all applicable?

Hello I have a hospital database and want to determine where the patient had a visit(s) to the emerg department and within 7 days they came back and were admitted.  I split the database out by index cases (only patient discharged to home - test_grpA) and then a table for possible readmits (which is any with the disposition of admitted which is 06 or 07 - test_grpB).  The code below starts out where I link the two tables and determine readmits but as you'll see, there are 3 different visits all linking to the same admit visit.  What I'd like to do is have one line of data for this readmit showing the oldest date within 7 days (registration 002) but also indicate number of ED visits within 7 days to that admit (3).  Any assistance greatly appreciated.

data test_grpA;

input @1 chart $5.

        @6 regn  $3.

        @9 disp $2.

        @11 AdmDate yymmdd8.

      @19 DisDate yymmdd8.

;

format admdate yymmdd10. disdate yymmdd10.;

cards;

A1234001012012032920120329

A1234002012012042920120429

A1234003012012043020120430

A1234004012012050220120502

A1234005012012070420120714

A1234006012012090120120907

A1234007012012122420121231

run;

data test_grpB;

input @1 chart $5.

        @6 regn  $3.

        @9 disp $2.

        @11 AdmDate yymmdd8.

      @19 DisDate yymmdd8.

;

format admdate yymmdd10. disdate yymmdd10.;

cards;

A4567008062012032920120329

A9999009072012012920120429

A8384010072012043020120430

A9200011062012050220120502

A1234012072012050320120503

A5555013062012090120120907

A6666014062012122420121231

run;

proc sql;

proc sql;

create table ED_Readmits as

select

  1. a.chart,
  2. a.regn,
  3. a.admdate,
  4. a.disp,
  5. a.disdate,
  6. b.regn as readm_regn,
  7. b.admdate as readm_admdate,
  8. b.disdate as readm_disdate,
  9. b.disp as readm_disp

from test_grpa as a

left join test_grpb as b

on a.chart = b.chart;

quit;

proc sort data=ED_Readmits; by chart admdate; run;

data ED_readm_n;

set ED_readmits;

readm_days=0;

readm=0;

if disdate ge '01jan12'd and readm_admdate ge '01jan12'd

            then readm_days=intck("day",disdate,readm_admdate);

if regn ne readm_regn and readm_days ge 0 and readm_days le 7 and

readm_disp in: ("06","07") then readm=1;

format admdate ddmmyy10. disdate ddmmyy10. 

      ;

if readm gt 0 then output;

run;

Ask a Question
Discussion stats
  • 0 replies
  • 168 views
  • 0 likes
  • 1 in conversation