SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Deciding direct vs indirect admissions!

Accepted Solution Solved
Reply
Contributor Dil
Contributor
Posts: 23
Accepted Solution

Deciding direct vs indirect admissions!

Hi all,

 

I am working on a dataset with admission data, which includes each hospital/facility a patient was admitted to before he is admitted to a rehab facility. The acute site is VGH and rehab site is GFS. I would like to count how many patients went directly from VGH to GFS and how many of them had an indirect admission (there were some admissions to other hospitals before they were admitted to GFS). Below is a simple dataset for illustration. Even though it is very easy to see if the admission was direct or indirect when I look at the admission records for each patient, I find it a bit hard to code it in SAS. Any suggestions would be appreciated. 

 

PT ID     FACILITY    DIRECT

1               VGH         YES         

1               GFS

2               VGH          NO

2                 A

2                GFS

3                VGH         NO

3                 B

3                GFS

 

Thanks,

D


Accepted Solutions
Solution
‎05-31-2016 03:07 PM
Super User
Posts: 9,681

Re: Deciding direct vs indirect admissions!

Does every first one of each group is VGH       ?

Does GFS always appear in each group ?

 

CODE NOT TESTED.

 

data want;

 merge have have(keep=PTID     FACILITY  rename=(PTID=_P    FACILITY=_F) firstobs=2);

 if PTID=_P and FACILITY='VGH' and _F='GFS' then DIRECT='YES';

 else DIRECT='NO ';

run;

 

View solution in original post


All Replies
Solution
‎05-31-2016 03:07 PM
Super User
Posts: 9,681

Re: Deciding direct vs indirect admissions!

Does every first one of each group is VGH       ?

Does GFS always appear in each group ?

 

CODE NOT TESTED.

 

data want;

 merge have have(keep=PTID     FACILITY  rename=(PTID=_P    FACILITY=_F) firstobs=2);

 if PTID=_P and FACILITY='VGH' and _F='GFS' then DIRECT='YES';

 else DIRECT='NO ';

run;

 

Contributor Dil
Contributor
Posts: 23

Re: Deciding direct vs indirect admissions!

Not every first row is VGH and yes GFS appear in each group although not necessarily the very last record for each PT. The logic/intuition you provided actually helpmed me solve the problem. Thanks for your help. 

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 249 views
  • 0 likes
  • 2 in conversation