Desktop productivity for business analysts and programmers

proc means output doesn't match results

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 81
Accepted Solution

proc means output doesn't match results


I'm generating mean and n statistics for two outcome variables, ip_count & bh_ed_count, by a third Yes/No categorical variable named "A" using proc means:

proc means data=ipdf_adults n mean;

where A in('Y','N');

by A;

var ip_count bh_ed_count;

output out=ipdf_adults_mean_a ;

run;

 

The results output listing for proc means is correct:

--------------------------------------------------------------- A=N ----------------------------------------------------------------

The MEANS Procedure

Variable Label N Mean

--------------------------------------------------

ip_count IP_COUNT 186 0.6021505

bh_ed_count BH_ED_COUNT 186 0.9301075

--------------------------------------------------

 

--------------------------------------------------------------- A=Y ----------------------------------------------------------------

Variable Label N Mean

--------------------------------------------------

ip_count IP_COUNT 54 0.5925926

bh_ed_count BH_ED_COUNT 54 1.2407407

--------------------------------------------------

However the output dataset incorrectly lists the mean values as 1:

A_TYPE__FREQ__STAT_ip_countbh_ed_count
N0186N186186
N0186MIN00
N0186MAX548
N0186MEAN11
N0186STD14
Y054N5454
Y054MIN00
Y054MAX49
Y054MEAN11
Y054STD12

Any ideas what's going on here? Thanks


Accepted Solutions
Solution
‎01-06-2015 11:51 AM
Grand Advisor
Posts: 17,325

Re: proc means output doesn't match results

My guess is rounding in the presentation, try changing the format of the data in the viewer or in a data step.

data ipdf_adults_mean_a;

set ipdf_adults_mean_a;

format ip_count bh_ed_count 12.4;

run;

If you want a different structure for the table, look into the STACKODS output.

Base SAS(R) 9.3 Procedures Guide, Second Edition

View solution in original post


All Replies
Solution
‎01-06-2015 11:51 AM
Grand Advisor
Posts: 17,325

Re: proc means output doesn't match results

My guess is rounding in the presentation, try changing the format of the data in the viewer or in a data step.

data ipdf_adults_mean_a;

set ipdf_adults_mean_a;

format ip_count bh_ed_count 12.4;

run;

If you want a different structure for the table, look into the STACKODS output.

Base SAS(R) 9.3 Procedures Guide, Second Edition

Frequent Contributor
Posts: 81

Re: proc means output doesn't match results

Thanks Reeza, that fixed the problem!

And I can insert the format statement into proc means to save myself a step:

proc means data=ipdf_adults n mean;

format ip_count bh_ed_count 12.4;

where A in('Y','N');

by A;

var ip_count bh_ed_count;

output out=ipdf_adults_mean_a ;

run;

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 375 views
  • 0 likes
  • 2 in conversation