BookmarkSubscribeRSS Feed
Anita_n
Pyrite | Level 9

Dear all,

am tring to calculate the mean and standard error of some data set using this code:

proc means data=mydataset;
var myvar
class diagnosisyear sex;
output out= myoutfile mean=meanresult stderr= stderr
run;

when I run this I get a table which looks like this

diagnosisyear   sex  myvar  mean  stderr

2011                  M      41        10       2

                           F      33         5        1

2012                  M      20          6        1

                           F      11          2        0.5

2013                  M      15          3       1

                          F        50         11      3

 

my problem here is that the diagnosis year for the females are not printed. I don't know why this is happening.

In my log I get this message: 

Multiple concurrent threads will be used to summarize data

Any help?

9 REPLIES 9
Oligolas
Barite | Level 11

hi,

the results are ok, the diagnosis year is not printed for a cleaner view on the results, it's only printed when it changes. F 33 5 1 relates to the diagnosis year 2011.

________________________

- Cheers -

Anita_n
Pyrite | Level 9

Is there any way to still make this to be printed. I will like to use the values to plot a graph. So it will be helpful if these are printed

Anita_n
Pyrite | Level 9

Hi, it's ok. I have got it working

Oligolas
Barite | Level 11

First if you do not need the summary statistics in myoutfile then run proc means with 'nway' and 'noprint' option.

Then run a proc report on myoutfile to fine tune the display.

proc means data=sashelp.class nway noprint;
var weight;
class sex age;
output out= myoutfile mean=meanresult stderr=standerr;
run;

proc sort data=myoutfile; by age sex;run;

data myoutfile;
   set myoutfile;
   order+1;
run;

proc report data=myoutfile;
columns order sex age meanresult standerr;
define order / order order=data noprint;
define sex / display;
define age / display;
run;

 

________________________

- Cheers -

Ksharp
Super User

That was supposed to be . If you want YEAR, you need another PROC PRINT to print it .

 

ods output summary=summary;
proc means data=sashelp.heart nway stackodsoutput;
var height;
class status bp_status;
output out= myoutfile mean=meanresult stderr= stderr ;
run;

proc print data=summary label noobs;run;
Tom
Super User Tom
Super User

You appear to already be sending the statistics you want to the dataset named in the OUTPUT statement.

 

If you don't want the print-out then add NOPRINT the PROC statement.

ballardw
Super User

What does your OUT=Myoutfile data set look like with regards to that year variable?

 

 

Anita_n
Pyrite | Level 9

@ballardw @Tom @Ksharp @Oligolas : Thank you all for the tips.

 

The myoutfile looks like this

diagnosisyear   sex  myvar  mean  stderr

2011                  M      41        10       2

                           F      33         5        1

2012                  M      20          6        1

                           F      11          2        0.5

2013                  M      15          3       1

                          F        50         11      3

 

but I wanted something like this

diagnosisyear   sex  myvar  mean  stderr

2011                  M      41        10       2

2011                  F      33         5        1

2012                  M      20          6        1

2012                  F      11          2        0.5

2013                  M      15          3       1

2013                  F        50         11      3

 

but it's ok, don't border yourself any longer,

I did some work arouds and could further use the dataset for further analysis 

PaigeMiller
Diamond | Level 26

Your output data set will show the data as you want. The HTML output will not.

 

Example:

 

proc means data=sashelp.class nway noprint;
    class age sex;
    var height weight;
    output out=_stats_ mean= std=/autoname;
run;

produces this data set named _STATS_

 

Screenshot 2022-03-29 074929.png

 

If you really really really want HTML output, then do a PROC PRINT of the above data set.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 9 replies
  • 766 views
  • 2 likes
  • 6 in conversation