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


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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

2 REPLIES 2
Reeza
Super User

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

RobF
Quartz | Level 8

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;

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
  • 2 replies
  • 1360 views
  • 0 likes
  • 2 in conversation