BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BigD
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

3 REPLIES 3
Reeza
Super User

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;

BigD
Calcite | Level 5

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;

DaveBirch
Obsidian | Level 7

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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