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

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

1 ACCEPTED SOLUTION

Accepted Solutions
10 REPLIES 10
Ksharp
Super User

Check proc freq;


proc freq data=sashelp.class order=freq;
 tables sex/binomial(ac wilson exact) alpha=.1;
run;

Xia Keshan

Doc_Duke
Rhodochrosite | Level 12

If you start with counts, the first example in the documentation

SAS/STAT(R) 13.1 User's Guide

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 ),

Silvertreetops
Obsidian | Level 7

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?

Kind Regards

*Calculate Weighted Counts from raw dataset;

PROC TABULATE

DATA=WORK.QUERY_FOR_LABELS_ADDED_0001

OUT = test;    

     VAR WT;

     CLASS QE5AM_Recode / MISSING;

     TABLE /* Row Dimension */QE5AM_Recode,

/* Column Dimension */WT*(Sum);

RUN;

*Drop unwanted variables;

DATA test_ii;

set test;

drop _TYPE_ _PAGE_ _TABLE_ WT_N;

RUN;

*Frequency to calculate Percentage;

proc freq data=test_ii noprint;

weight WT_sum;

tables QE5AM_Recode / nocum out=test_iii;

run;

*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’ ;

run;

*Print Results;

Proc Print data=test_iv;

run;


SASKiwi
PROC Star

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.


Silvertreetops
Obsidian | Level 7

Hello SASKiwi,

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?

regards,

SASKiwi
PROC Star

Unfortunately I haven't explored UNIVARIATE enough to give you a better answer.

However there is another example that does frequency counts:

http://support.sas.com/documentation/cdl/en/procstat/67528/HTML/default/viewer.htm#procstat_univaria...

Does this give you enough to at least get your frequencies? If so can you try the other example's options on top?

Silvertreetops
Obsidian | Level 7

Thanks again for your efforts SASKiwi - unfortunatly the earlier option for confidence intervals just produces a seperate table with the quantiles. Any more ideas?

SASKiwi
PROC Star

Have a look here at all of the options under confidence intervals.

http://support.sas.com/kb/30/333.html

stat_sas
Ammonite | Level 13

Try proc surveyfreq

Silvertreetops
Obsidian | Level 7

Thank you all for your help. PROC SURVEYFREQ is what I was after.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 10 replies
  • 6547 views
  • 0 likes
  • 5 in conversation