It ought to be easier than this and perhaps I could have found an easier way if I had more patience than the average ant or very young infant. However, I don’t.
Here was the problem. I wanted control charts for two different variables, satisfaction with care, surveyed at discharge, and satisfaction with care 3 months after discharge.
The data was given in the form of the number of patients out of a sample of 500 who reported being unsatisfied. PROC SHEWHART does not have a WEIGHT statement. You could try using the WEIGHT statement in PROC MEANS but that won’t work. It will give you the correct means if you have the number unsatisfied (undisc = 1) and the number satisfied (undisc =0) out of 500, but the incorrect standard deviation because the N will be 2, according to SAS.
So, here is what I did and it was not elegant but it did work.
- I created two data sets, named q4disc and q4disc3, keeping the month of discharge and the number dissatisfied at discharge and dissatisfied 3 months later, respectively.
- I read in the 3 values I was given, month of sample, number unsatisfied at discharge and number unsatisfied 3 months later.
- Now, I am going to create a data set of raw data based on the numbers I have. First, in a do loop, for as many as people said they were unsatisfied, I set the value of undisc (unsatisfied at discharge) to to 1 and output a record to the q4disc dataset.
- Next, in a do loop for 500- the number dissatisfied, I set undisc = 0 and output a record to the same dataset.
- Now, repeat steps 3 & 4 to create a data set of the values of people unhappy 3 months after discharge.
- Following the programming statements are the original data.
So, now, I have created two data sets of 6,000 records each with three variables. Doesn’t seem that efficient of a way to do it but now I have the data I need and it didn’t take long and doesn’t take up much space.
data q4disc (keep = undisc month) q4disc3 (keep = undisc3 month) ;
input month $ discunwt disc3unwt ;
Do I = 1 to discunwt ;
undisc = 1 ;
output q4disc ;
Do J = 1 to (500-discunwt) ;
undisc = 0 ;
Do k = 1 to disc3unwt ;
undisc3 = 0 ;
output q4disc3 ;
Do x = 1 to (500 -disc3unwt) ;
undisc3 = 1 ;
JAN 24 17
FEB 44 24
MAR 36 15
APR 18 8
MAY 16 11
JUN 19 7
JUL 17 11
AUG 18 9
SEP 27 10
OCT 26 15
NOV 29 12
DEC 26 11
proc shewhart data=WORK.Q4disc;
xschart undisc * month /;
“The XSCHART statement creates and charts for subgroup means and standard deviations, which are used to analyze the central tendency and variability of a process.”
For the three months after discharge variable, just do another PROC SHEWHART with q4disc3 as the dataset and undisc3 as the measurement variable.
OR , once you have the dataset created, you can get the chart using SAS Studio by selecting the CONTROL CHARTS task
Either way will give you this result:
Support my day job AND get smarter. Buy Fish Lake for Mac or Windows. Brush up on math skills and canoe the rapids.
For random advice from me and my lovely children, subscribe to our youtube channel 7GenGames TV