SAS Programming

DATA Step, Macro, Functions and more
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

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1325 views
  • 2 likes
  • 6 in conversation