Date: Tue, 9 Sep 2003 12:21:28 -0400
Reply-To: Bruce Johnson <bjohnson@SOLUCIENT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Bruce Johnson <bjohnson@SOLUCIENT.COM>
Subject: DATA Step -> SQL Conversion
I have a colleague who wants to convert data step code into SQL. I'm not a
SQL whiz, but I'm pretty sure this can be done. Can anyone help? The code
to convert is as follows:
***Set up a test file***;
data a;
input hosp $ drg los;
cards;
A 1 13
A 1 9
A 1 15
A 2 24
A 2 1
A 2 52
A 2 24
;
run;
proc sort data=a;
by hosp drg;
run;
***Get the total discharges, number of records
with LOS > 14 and number of records with LOS > 30***;
data b;
set a;
by hosp drg;
if first.drg then do;
totdis=0;
los14=0;
los30=0;
end;
totdis=totdis+1;
if los>14 then los14=los14+1;
if los>30 then los30=los30+1;
retain totdis los14 los30;
if last.drg then output;
run;
_______________________________
Bruce A. Johnson
Senior Data Analyst
Solucient, LLC
(847) 440-9635
bjohnson@solucient.com
This message is a private communication. It may contain information that is
confidential and legally protected from disclosure. If you are not an
intended recipient, please do not read, copy or use this message or any
attachments, and do not disclose them to others.
Please notify the sender of the delivery error by replying to this message,
and then delete it and any attachments from your system. Thank you.
Solucient LLC.