BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8

Hello,

I am trying to create a control chart(p-chart)  for hospital data shown below .

The SAS system asks me to give the variable for subgroupn= option in Proc shewhart and i have no clue at all..any help is highly apreciated.

i have a total of 42 records in my dataset (22 records for Hospital 1 and 22 records for Hospital 2). and want a control chart for each hospital seperately....and the code used is shown below....

What should i have as the subgroupn option????

 

proc shewhart data=have;
pchart cases_per_1000days*month;
where Hospital=University1';
label DVT = " DVT per 1000 days"

 

 

HOSPITAL   YEAR    MONTH   SERIOUS_ CASES    PATIENT_DAYS   CASES_PER_1000days

University1   2014-01    Jan                       19                     8924                     2.129

University1    2014-02    Feb                      17                    7169                      2.371

University2    2014-01    Jan                       01                   1571                      0.637

University2     2014-02    Feb                      02                   1462                     1.367

 

 

 

     

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @robertrao,

 

Let me first say that I'm not familiar with control charts and I have not licensed SAS/QC (which is required for PROC SHEWHART). But I've looked into the documentation of the SHEWHART procedure and some documents dealing with control charts in health-related contexts I found on the internet. Based on this information (and my biostatistical experience), I think that a u chart would be more appropriate for your data than a p chart. See, for example, Table 1 in this document. Or do you have good reasons to assume that the number of "serious cases" within a given number of patient days follows a binomial distribution rather than a Poisson distribution?

 

Assuming that a u chart is more appropriate, the statement uchart serious_cases*month / subgroupn=patient_days; should be valid. However, this would measure the rate in cases per patient day. Therefore, I suggest that you create a new variable, say th_pat_days=patient_days/1000, in your HAVE dataset and replace patient_days by th_pat_days in the above UCHART statement. In the actual chart this replacement should only change the unit, not the shape of the graph.

 

This would be in line with Example 18.33 in the documentation. There they also have varying, non-integer denominators (values of the variable specified in the SUBGROUPN= option).

 

Your variable CASES_PER_1000days would not be used in the UCHART statement. (Btw, 1.367 should read 1.368 in your data, because 2/1.462=1.3679...) SAS would compute these rates automatically from serious_cases and th_pat_days.

 

(And please add the missing single quote in your WHERE statement.)

 

 

 

 

 

 

 

View solution in original post

6 REPLIES 6
mohamed_zaki
Barite | Level 11

What CASES_PER_1000days represent and how you calculate it?

FreelanceReinh
Jade | Level 19

Hello @robertrao,

 

Let me first say that I'm not familiar with control charts and I have not licensed SAS/QC (which is required for PROC SHEWHART). But I've looked into the documentation of the SHEWHART procedure and some documents dealing with control charts in health-related contexts I found on the internet. Based on this information (and my biostatistical experience), I think that a u chart would be more appropriate for your data than a p chart. See, for example, Table 1 in this document. Or do you have good reasons to assume that the number of "serious cases" within a given number of patient days follows a binomial distribution rather than a Poisson distribution?

 

Assuming that a u chart is more appropriate, the statement uchart serious_cases*month / subgroupn=patient_days; should be valid. However, this would measure the rate in cases per patient day. Therefore, I suggest that you create a new variable, say th_pat_days=patient_days/1000, in your HAVE dataset and replace patient_days by th_pat_days in the above UCHART statement. In the actual chart this replacement should only change the unit, not the shape of the graph.

 

This would be in line with Example 18.33 in the documentation. There they also have varying, non-integer denominators (values of the variable specified in the SUBGROUPN= option).

 

Your variable CASES_PER_1000days would not be used in the UCHART statement. (Btw, 1.367 should read 1.368 in your data, because 2/1.462=1.3679...) SAS would compute these rates automatically from serious_cases and th_pat_days.

 

(And please add the missing single quote in your WHERE statement.)

 

 

 

 

 

 

 

robertrao
Quartz | Level 8

Thanks for all the inputs. The post from you was very informative and i want to thank you once again.

Lastly, when i get the u-chart i only have 3 sigma Limit marked apart from the UCL and LCL.

Is there a way we can get the code for marking the 2 sigma limit and 1 sigma limit .

 

Regards

FreelanceReinh
Jade | Level 19

Thanks for the like and accepting my solution.

 

According to the documentation, there are essentially two ways to specify the width of the control limits (like 3s😞 either through the SIGMAS= option (of the UCHART statement, I think), which has the default 3, or through a LIMITS= dataset (and there in variable _SIGMAS_) to be specified in the LIMITS= option of the PROC SHEWHART statement (see this example). But also the TABLE= input dataset seems to contain the variable _SIGMAS_. However, it is not clear to me if any of these methods allows for more than one multiple of s at the same time. This old discussion (concerning the XCHART statement, though) suggests that this is perhaps not possible (or was not possible back in 2003). But in any case, as a last resort, it should be possible to create the chart (with somewhat more effort) by either creating an overlay chart where simply two or three charts (each showing only one pair of sigma limits, otherwise being identical) are overlaid or by drawing the desired additional lines using the SAS/GRAPH Annotate facility (if traditional graphics are used) or corresponding features of ODS graphics, respectively.

robertrao
Quartz | Level 8

Hello Freelance,

One other question is that the x-axis had labels which are two crowded.

Is there an option in the u-chart axis options which can make the labels allign vertical or at an angle?

 

i have the labels as follows:

2014-01 2014-02 2014-03 etc etc

 

thanks

FreelanceReinh
Jade | Level 19

According to the documentation, the TURNHLABELS option (valid for traditional graphics) "turns the major tick mark labels for the horizontal (subgroup) axis so that they are strung out vertically." Perhaps another way to save space would be to omit the (redundant) year from the labels and write it into the axis label or the title or to specify the year only at the January tick mark.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1992 views
  • 2 likes
  • 3 in conversation