Date: Thu, 29 Oct 2009 09:57:15 +0100
Reply-To: Fernández Rodríguez, Dani
<DFernandez@CST.CAT>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Fernández Rodríguez, Dani
<DFernandez@CST.CAT>
Subject: Re: Hospital patient visit summary
In-Reply-To: A<200910290213.n9SGMJtV017711@malibu.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-1"
data have;
input PAT_ID $ month1 month2 month3;
cards;
CONCORD 0 3 8
CONCORD 0 0 1
ST-JOHN 2 4 12
ST-JOHN 8 7 8
;;
run;
* I understand what you need is the sum of months result at the first month
with data
different than zero value;
data need;
set have ;
array monz(3) month1 - month3;
do y=1 to 3;
if monz(y) NE 0 then
monz(y)=sum(of month:); else monz(y)=.;
end;
if (month3 > month2 and (month2 NE . OR month1 NE .)) then month3=.;
if (month2 > month1 and (month1 NE .)) then month2=.;
drop y;
run;
proc summary data=need nway;
class pat_id;
*change to different time periods depending on the original data;
var month1 month2 month3;
output out=patient_summaries (drop=_:) sum()= ;
run;
data patient_summaries;
set patient_summaries;
*change to different time periods depending on the original data;
Total_patients=sum(month1, month2, month3);
run;
I hope it is helpful.
Daniel Fernandez.
Terrassa Hospital- Barcelona.
-----Mensaje original-----
De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] En nombre de Donald Harrison
Enviado el: dijous, 29 / octubre / 2009 03:14
Para: SAS-L@LISTSERV.UGA.EDU
Asunto: Hospital patient visit summary
Hello SAS Experts, sorry to be a pain asking for your help once again but
I have been asked to provide a summary for our State Health Department
that looked like the one output I provided below and I am stumped as I
only started using SAS recently, any help is greatly appreciated.
My data now includes an additional column of the hospital the patient
visited and I need the following summary.
Last_month last_6_months last_1_year Total_Patients
ST-JOHN 50 40 30 120
WESTMEAD 60 40 20 120
CONCORD 30 20 10 60
PRINCE 80 60 40 180
OF WALES
Cheers
Don