## Admissions data (similar to last question)

Solved
Occasional Contributor
Posts: 16

# Admissions data (similar to last question)

So I asked a question a few days ago and ended up figuring it out. Now I have to do more with similar data. I have a dataset with variables:

ID = patient id
FACILITY = facility id
Days_Since_Last_Adm = days since the patient was last admitted to the hospital

Ex Data:

 ID FACILITY Admission admission_number DAYS_SINCE_LAST_ADM CumulativeDaysSinceAdm 1 24 2/14/2012 1 0 0 1 24 3/3/2012 2 18 18 2 13 2/1/2012 1 0 0 2 13 5/11/2012 2 100 100 2 13 5/21/2012 3 10 110 2 13 6/13/2012 4 23 133 2 13 6/25/2012 5 12 145 2 13 7/13/2012 6 18 163 2 13 7/20/2012 7 7 170 2 13 8/6/2012 8 17 187 2 13 8/22/2012 9 16 203 2 13 10/8/2012 10 47 250 2 13 10/18/2012 11 10 260

Accepted Solutions
Solution
‎01-03-2013 03:01 PM
Frequent Contributor
Posts: 81

## Re: Admissions data (similar to last question)

data one;

datalines;

1 24 2/14/2012  1 0 0

1 24 3/3/2012   2 18 18

2 13 2/1/2012   1 0 0

2 13 5/11/2012  2 100 100

2 13 5/21/2012  3 10 110

2 13 6/13/2012  4 23 133

2 13 6/25/2012  5 12 145

2 13 7/13/2012  6 18 163

2 13 7/20/2012  7 7 170

2 13 8/6/2012   8 17 187

2 13 8/22/2012  9 16 203

2 13 10/8/2012  10 47 250

2 13 10/18/2012 11 10 260

;

run;

proc sort data=one;  by id admission;  run;

data two;

set one;

retain fdate;

if first.id then do; index='Y'; fdate=admission; end;

format fdate date9.;

run;

All Replies
Solution
‎01-03-2013 03:01 PM
Frequent Contributor
Posts: 81

## Re: Admissions data (similar to last question)

data one;

datalines;

1 24 2/14/2012  1 0 0

1 24 3/3/2012   2 18 18

2 13 2/1/2012   1 0 0

2 13 5/11/2012  2 100 100

2 13 5/21/2012  3 10 110

2 13 6/13/2012  4 23 133

2 13 6/25/2012  5 12 145

2 13 7/13/2012  6 18 163

2 13 7/20/2012  7 7 170

2 13 8/6/2012   8 17 187

2 13 8/22/2012  9 16 203

2 13 10/8/2012  10 47 250

2 13 10/18/2012 11 10 260

;

run;

proc sort data=one;  by id admission;  run;

data two;

set one;

retain fdate;

if first.id then do; index='Y'; fdate=admission; end;

format fdate date9.;

run;

Occasional Contributor
Posts: 16

## Re: Admissions data (similar to last question)

This worked! Thank you so much!

Super User
Posts: 23,778

## Re: Admissions data (similar to last question)

I think this will give you what you want;

data want;

set have;

by id;

retain index index_date ;

if first.id then index=0;

if DAYS_SINCE_LAST_ADM>30 or first.id then do;

index=index+1;

end;

run;

🔒 This topic is solved and locked.