DATA Step, Macro, Functions and more

How to calculate standard deviation or confidence interval for a proportion?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

How to calculate standard deviation or confidence interval for a proportion?

Hi,

I am calculating an overall 5-year rate for survivors (#ppl surviving after 5 years after diagnosis / # ppl diagnosed with cancer). My dataset is quite simple, it has pt_id, clinic_id and survival (0/1). I have decided to ignore my clinic_id since I am interested in the overall rate. How do I use SAS to calculate the standard deviation? PROC FREQ doesn't have anything I can find easily. 

Or should I be using a confidence interval instead? 

Ultimately I'd like to know if each of my clinics is statistically higher or lower than my overall clinic rate.

Thanks.


Accepted Solutions
Solution
‎05-03-2017 03:08 PM
Super User
Posts: 11,335

Re: How to calculate standard deviation or confidence interval for a proportion?

Posted in reply to sharonlee

Proc Mean or Summary may work for simple analysis. The Mean of a 0/1 coded variable is actually the percentage of 1's.

 

Proc summary data = have;

    class clinic_id;

    var survival;

    output out= want mean=rate Lclm = LowerCl UCLM=UpperCl;

run;

The _type_ variable will have a value of 0 indicating overall rate or limits for the data and each clinic will have it's result on a separate line.

 

Or a more human readable:

proc tabulate data=have;
   class clinic;
   var survival;
   table all clinic,
         survival*(mean='Rate'*f=percent8.2  
                   lclm='Lower CL'**f=percent8.2 
                   uclm='Upper CL'**f=percent8.2);
   ;
run;

The results will be rate of 1 responses.

 

View solution in original post


All Replies
Solution
‎05-03-2017 03:08 PM
Super User
Posts: 11,335

Re: How to calculate standard deviation or confidence interval for a proportion?

Posted in reply to sharonlee

Proc Mean or Summary may work for simple analysis. The Mean of a 0/1 coded variable is actually the percentage of 1's.

 

Proc summary data = have;

    class clinic_id;

    var survival;

    output out= want mean=rate Lclm = LowerCl UCLM=UpperCl;

run;

The _type_ variable will have a value of 0 indicating overall rate or limits for the data and each clinic will have it's result on a separate line.

 

Or a more human readable:

proc tabulate data=have;
   class clinic;
   var survival;
   table all clinic,
         survival*(mean='Rate'*f=percent8.2  
                   lclm='Lower CL'**f=percent8.2 
                   uclm='Upper CL'**f=percent8.2);
   ;
run;

The results will be rate of 1 responses.

 

Occasional Contributor
Posts: 17

Re: How to calculate standard deviation or confidence interval for a proportion?

Thanks, ballardw!

The proc summary didn't work for reason reason (I get all 0 values), but the proc tabulate worked great, except that I had to change it so that there was only one astrix instead of two (modified below).

Appreciate you taking the time to help out!

proc tabulate data=have;
   class clinic;
   var survival;
   table all clinic,
         survival*(mean='Rate'*f=percent8.2  
                   lclm='Lower CL'*f=percent8.2 
                   uclm='Upper CL'*f=percent8.2);
   ;
run;

  

Super User
Posts: 19,767

Re: How to calculate standard deviation or confidence interval for a proportion?

Posted in reply to sharonlee

If you're trying to compare these, a Chi-Square (via PROC FREQ) test would be appropriate to test the overall distribution. 

To do the pairwise comparisons, make sure to include a Bonferonni correction for multiple testing but ideally you should calculate an age/sex standardized rate unless you have reason to believe your clinics have the same patient distribution. 

 

If you decide to standardize, check out PROC STRATE

 

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_stdrate_exam...

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 186 views
  • 1 like
  • 3 in conversation