DATA Step, Macro, Functions and more

How to calculate confidence interval of mean by proc univariate

Accepted Solution Solved
Reply
Super Contributor
Posts: 312
Accepted Solution

How to calculate confidence interval of mean by proc univariate

[ Edited ]

in proc means one can use CLM to get the confidence interval of the mean. How to output the CLM to a dataset?

proc means data=adxe N NMISS CLM  ;
  by trtp;
  var aval;
  where aval >.; 
/*  output out=TFMT2RD n=n mean=mean std=sd median=median min=min max=max q1=q1 q3=q3  ;*/
run;

 

 

in proc univariate, what is the option to do thid? cibasic (alpha=0.05)? 

what are the output options to get the 95% CI of mean? 

 

proc univariate data=adxe cibasic (alpha=0.05) noprint;
  by trtp;
  var aval;
  where aval >.; 
  output out=TFMT2RD n=n mean=mean std=sd median=median min=min max=max q1=q1 q3=q3  ;
run;

 

 

 

 


Accepted Solutions
Solution
‎03-16-2017 04:55 PM
PROC Star
Posts: 7,356

Re: How to calculate confidence interval of mean by proc univariate

Note: You can also output them directly, but the above method is a lot more versatile. Additionally, if you use any of the special missing values (e.g., .A, .B, etc), you can capture all of them by using where not missing(variablename). e.g.:

 

data class;
  set sashelp.class;
  if _n_ in (2,4,6) then weight=.;
  else if _n_ in (3,5,7) then weight=.A;
run;

proc means data=class N NMISS CLM nway ;
  class sex;
  var weight;
  where weight >.;
  output out=want  /autoname;
run;

proc summary data=class N NMISS CLM  nway;
  class sex;
  var weight;
  where weight >.;
  output out=want2  /autoname;
run;

proc means data=class N NMISS CLM nway ;
  class sex;
  var weight;
  where not missing(weight);
  output out=want3  /autoname;
run;

proc summary data=class N NMISS CLM  nway;
  class sex;
  var weight;
  where not missing(weight);
  output out=want4  /autoname;
run;

Art, CEO, AnalystFinder.com

View solution in original post


All Replies
PROC Star
Posts: 7,356

Re: How to calculate confidence interval of mean by proc univariate

You can use the following method with any procedure:

 

ods trace on;
proc means data=sashelp.class N NMISS CLM;
  class sex;
  var weight;
  where weight >.; 
/*  output out=TFMT2RD n=n mean=mean std=sd median=median min=min max=max q1=q1 q3=q3  ;*/
run;
ods trace off;

/*get the name of the desired file from the log*/
ods output Means.Summary=want;
proc means data=sashelp.class N NMISS CLM;
  class sex;
  var weight;
  where weight >.; 
/*  output out=TFMT2RD n=n mean=mean std=sd median=median min=min max=max q1=q1 q3=q3  ;*/
run;

Art, CEO, AnalystFinder.com

 

Solution
‎03-16-2017 04:55 PM
PROC Star
Posts: 7,356

Re: How to calculate confidence interval of mean by proc univariate

Note: You can also output them directly, but the above method is a lot more versatile. Additionally, if you use any of the special missing values (e.g., .A, .B, etc), you can capture all of them by using where not missing(variablename). e.g.:

 

data class;
  set sashelp.class;
  if _n_ in (2,4,6) then weight=.;
  else if _n_ in (3,5,7) then weight=.A;
run;

proc means data=class N NMISS CLM nway ;
  class sex;
  var weight;
  where weight >.;
  output out=want  /autoname;
run;

proc summary data=class N NMISS CLM  nway;
  class sex;
  var weight;
  where weight >.;
  output out=want2  /autoname;
run;

proc means data=class N NMISS CLM nway ;
  class sex;
  var weight;
  where not missing(weight);
  output out=want3  /autoname;
run;

proc summary data=class N NMISS CLM  nway;
  class sex;
  var weight;
  where not missing(weight);
  output out=want4  /autoname;
run;

Art, CEO, AnalystFinder.com

Valued Guide
Posts: 505

Re: How to calculate confidence interval of mean by proc univariate

I am a little confused don't you get the intervals

title 'Analysis of Female Heights';
ods select BasicIntervals;
proc univariate data=sashelp.class cibasic;
   var Height;
run;


The UNIVARIATE Procedure
Variable:  HEIGHT

     Basic Confidence Limits Assuming Normality

Parameter          Estimate     95% Confidence Limits

Mean               62.33684      59.86567    64.80801
Std Deviation       5.12708       3.87408     7.58204
Variance           26.28690      15.00852    57.48740

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 180 views
  • 0 likes
  • 3 in conversation