Hi,
I have the following scenarios.
PAT is the patient
ENC is the encounter ID 's for that patient
CNT is the count of the number of encounters
EM is emergency flag
IP is Inpatient flag
OP is Outpatient flag
We are trying to see if the EM encounters turned to IP or OP or DISCHARGE based on the flags
If they have EM=1 and IP=0 and OP=0 then that means they are discharged from EM directly
I have presented cases how to flag if present as a single record or multiple records and the three scenarios
PAT ENC ADMIT CNT EM IP OP
robertrao wrote:
PAT ENC ADMIT CNT EM IP OP
I don't see the difference between these records that indicate a different outcome. Are you looking to create code that says they were treated differently or 3 codes indicating 3 outcomes? What is the desired output?
Hi,
How about:
data want;
set have;
by pat enc;
length result $9;
if last.enc;
if ip then
result='IP';
else
if op then
result='OP';
else
result='DISCHARGE';
run;
If it is not what you then please provide the required output records and also what should happen if EM is never 1 for a patient or is that not possible?
Regards,
Amir.
How about the following code
data have ;
set have;
count=1;
run;
proc sort data=have;
by PAT ENC ADMIT ;
run;
proc summary data=have missing nway;
by PAT ENC ADMIT ;
var EM IP OP count;
output out=want(drop=_:) sum=;
run;
data want;
set want;
format result $20.;
if EM=1 then do;
if IP=1 and OP=0 then result='EM to IP';
else if IP=1 and OP=1 then result='IP to OP';
else if IP=0 and OP=1 then result='EM to OP';
else if IP=0 and OP=0 then result='EM to DISCHARGE';
end;
run;
proc sort data=want out=want1(keep=PAT ENC ADMIT result);
by PAT ENC ADMIT ;
run;
data final;
merge have(in=a) want1(in=b);
by PAT ENC ADMIT ;
if a;
run;
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.
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.