Hi,
I have a list of 150 patients with Length of stay in the hospital. I will need to create an SPC for LOS. Could you please guide me on where to start?
I think I will need to use PROC Shewhart with the I-MR (Individual-Moving Range) Chart.
The LOS variable is like 5 days /7 days/ etc. Am I correct in using the I-MR chart?
I need help with the code for the SPC chart.
or should I use C chart for length of stay hospital variable?
one column is health service number another column is length of stay of patient in hospital based on day.
Thank you
Format does not eliminate duplicate records. Your input data set could have many records by quarter.
Try PROC SUMMARY to aggregate by quarters.
Can you show an example of your data? For each patient, do you have an admission date and length of stay? Or do you only have length of stay?
Do you know the order in which these patients were admitted?
When you say I-MR chart, are you thinking the x-axis would be patient ID? So you would be looking to see if there was special cause variation among the patients? That seems a bit unusual, I would assume some patients are sicker than others. Unless you believe that all of these patients have the same severity of illness when admitted?
Or do you have, 10 patients admitted each day, for a two week period? And you're thinking the x-axis would be be admission date? So you would be looking for special cause variation between admission dates?
Thank you for response, I have an admission date and LOS for each patient.
The x-axis should be the admission date, not the patient ID.
I tried to create an I-MR chart to have an admission date on the x-axis by using the following code:
proc sort data=LOS;
by Admit_Date_;
run;
proc shewhart data=LOS;
irchart Total_LOS_Days*Admit_Date_ / TOTPANELS=1 ;
run;
but my issue is there is a few duplicate admission dates for around 10 patients, so I will get the following error with this code :
/*ERROR: The values of the subgroup variable Admit_Date_ are not unique, or they are not sorted in increasing order.*/
When I run “nodupkey” in proc sort then I can have I-MR chart without error, but I don’t want to remove any patients.
I need help in this matter.
Thanks
Not sure how to advise. If you had one patient per admission date, you could make an I-MR chart of admission dates. If you had a group of patients for each admission date, you could make an X-R chart, or other chart looking at the mean length of stay for each admission date. But if most of your groups are size=1, and a few of your groups are size=2, that probably won't work, it might error or just exclude all the groups with size=1.
Can you collect more data?
Just for fun, I guess , you could calculate the mean (or median) length of stay for each admission date. And then make an I-MR chart of those values. Not sure that would be reasonable/meaningful, but it would give you a chart.
I have admission date in date9. format, which I intend to convert to yyQ7. format to aggregate by quarters, as I want each quarter to represent a single subgroup to solve the issue.
Now, the issue is that even after converting dates into quarters, they are not being recognized as singular subgroups.
In the output from outhistory, instead of seeing one entry per quarter (e.g., one entry for 2019Q3), I see multiple entries for the same quarter, such as several occurrences of 2019Q3.
It sounds like the aggregation step is not performing as expected.
data LOS_quarter;
set LOS;
format Admit_Date_ yyQ7.;
run;
proc shewhart data=LOSopen_quarter ;
xchart Total_LOS_Days * Admit_Date_ /outhistory= LOShist
;
run;
proc print noobs;run;
Format does not eliminate duplicate records. Your input data set could have many records by quarter.
Try PROC SUMMARY to aggregate by quarters.
I was playing with PROC SHEWHART recently and was surprised that it wouldn't use the formats for grouping. I ended up creating a character variable with the formatted value. Something like (untested):
data LOS_quarter;
set LOS;
AdmitYYQ=put(Admit_Date_,yyQ7.);
run;
proc shewhart data=LOSopen_quarter ;
xchart Total_LOS_Days * AdmitYYQ /outhistory= LOShist
;
run;
/*ERROR: The values of the subgroup variable Admit_Date_ are not unique, or they are not sorted in increasing order.*/
Did you see if your values for Admit_Date_ are sorted in increasing order?
If they are in increasing order, then you don't have unique values for Admit_Date_ and so this type of chart cannot be drawn. You would need to do something other than this type of Shewhart Chart, or modify the data so it can be drawn.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.