08-25-2014 04:02 AM
Hello, Does Enterprise Guide provide a way to calculate confidence intervals for proportions without having to write your own code? The formula I am referring to is: p +- 1.96*SQRT(p(-1p)/n) If there is no way to write this without code, does anyone have a reference to, or is able to write some code that calculates that nicely? I am also interested to hear how both a point-and-click, and code method deals with non-response. Thank you
08-25-2014 09:02 AM
If you start with counts, the first example in the documentation
shows how to incorporate them.
As far as missing, how you address it depends on how it occurred. MCAR can generally be ignored, the missing data can be assumed to have equal impact on all groups. In those cases, your effective sample size is the non-missing observations. If the reason for the missing is known (MNAR), then you can incorporate that as a separate category in any statistical test. Alternately, for both MAR and MNAR, you can use PROC MCMC to actually model the process. The MCMC documentation has a good discussion of missingness ( SAS/STAT(R) 13.1 User's Guide ),
08-25-2014 11:34 PM
Hi All again,
Thank you for your replies.
@Ksharp - I am looking for the confidence intervals of frequencies, not just the mean
@Doc@Duke - I couldnt seem to see an example of a confidence interval for frequencies in your links either sorry.
Based on this - http://www2.sas.com/proceedings/sugi25/25/btu/25p069.pdf (p4) I have edit some code of my own to try and acomplish my outcome of confidence intervals for frequencies.
This code attempts to calculate 95% confidence intervals for QE5AM_Recode, with frequency being a sum of the WT variable. I am an amature coder so it is probably very bad code. Also, it still outputs the first table and I dont want it too. Lastly, I have to enter the n value for the confidence interval calculation (in this case the sum of WT) manually. Ideally, this value would be calculted automatically based on the dataset that was entered.
Is anyone able to help make this more elagent?
*Calculate Weighted Counts from raw dataset;
OUT = test;
CLASS QE5AM_Recode / MISSING;
TABLE /* Row Dimension */QE5AM_Recode,
/* Column Dimension */WT*(Sum);
*Drop unwanted variables;
drop _TYPE_ _PAGE_ _TABLE_ WT_N;
*Frequency to calculate Percentage;
proc freq data=test_ii noprint;
tables QE5AM_Recode / nocum out=test_iii;
*Add Confidence Intervals to dataset;
data test_iv; set test_iii ;
P = PERCENT/100 ;
*N is manually added;
N = 2539;
LB = P - ( 1.96*SQRT( P*(1-P)/N ) ) ;
* reset lower bound to 0 if <0 ;
IF LB < 0 THEN LB = 0 ;
UB = P + ( 1.96*SQRT( P*(1-P)/N ) ) ;
* reset upper bound to 1 if >1 ;
IF UB > 1 Then UB = 1 ;
label p = ’Proportion Cured’
LB = ’Lower Bound’
UB = ’Upper Bound’ ;
Proc Print data=test_iv;
08-26-2014 12:20 AM
Have you looked at PROC UNIVARIATE?
It can do confidence intervals like this example: http://support.sas.com/documentation/cdl/en/procstat/67528/HTML/default/viewer.htm#procstat_univaria...
Perhaps with a bit of tweaking it can do what you want.
08-26-2014 09:15 PM
The table in your link does look really close to what I'm looking for. The only problem is that instead of producing confidence intervals for the various quantiles, I want it for proportions from a frequency. I tried to change it to do this, but didn't really get anywhere. Are you able to help?
08-26-2014 09:34 PM
Unfortunately I haven't explored UNIVARIATE enough to give you a better answer.
However there is another example that does frequency counts:
Does this give you enough to at least get your frequencies? If so can you try the other example's options on top?
08-26-2014 10:36 PM
Thanks again for your efforts SASKiwi - unfortunatly the earlier option for confidence intervals just produces a seperate table with the quantiles. Any more ideas?
Need further help from the community? Please ask a new question.