Help using Base SAS procedures

Active clients based on admission and discharge dates

Accepted Solution Solved
Reply
Contributor
Posts: 36
Accepted Solution

Active clients based on admission and discharge dates

Hello,

I have a set of admission dates and discharge dates for the past 10 years that I want to turn into a graph of active cases for each date over the time period of interest.

Have:

Admission_DateDischarge_Dateid
22-Nov-1126-Jul-131
17-Dec-1201-May-142
30-Jan-1307-Sep-133
05-Feb-1308-Aug-134
18-Mar-1316-Aug-135
10-May-1304-Jun-146
23-May-1320-Jan-147
12-Aug-1331-Mar-148
etc

so client 1 was active between Nov 22, 2011 to Jul 26, 2013...

want (example)

DateActive Clients (count)
22-Nov-1120
23-Nov-1118
24-Nov-1118
25-Nov-1118
26-Nov-1120
27-Nov-1120
etc.

Which can be easily graphed.

Thanks for you help.

Bruce


Accepted Solutions
Solution
‎10-21-2014 10:33 PM
Grand Advisor
Posts: 16,933

Re: Active clients based on admission and discharge dates

An easy coding but possibly generates a large data set:

data step1;

set have;

do date=admission_date to discharge_date;

     output;

end;

run;

proc freq data=step1;

table date/out=active_clients;

run;

View solution in original post


All Replies
Solution
‎10-21-2014 10:33 PM
Grand Advisor
Posts: 16,933

Re: Active clients based on admission and discharge dates

An easy coding but possibly generates a large data set:

data step1;

set have;

do date=admission_date to discharge_date;

     output;

end;

run;

proc freq data=step1;

table date/out=active_clients;

run;

Contributor
Posts: 36

Re: Active clients based on admission and discharge dates

That's pretty much it. I made the following modifications to get exactly what I needed.

data step1;

set have;

by id;

length_of_stay =discharge_date - admission_date;

by id;

do i= 1 to  length_of_stay by 1;;

count_date = ADMISSION_DATE + I;

OUTPUT;

end;

FORMAT count_date DATE9.;

run;

Contributor
Posts: 25

Re: Active clients based on admission and discharge dates

If you are concerned about generating too large a data set, then modify Reeza's code to use a view:

data step1 / view=step1;  ** data step will be processed "in-line" when used without occupying excessive space **;

set have;

do date=admission_date to discharge_date;

     output;

end;

run;

proc freq data=step1;

table date/out=active_clients;

run;

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 184 views
  • 2 likes
  • 3 in conversation