DATA Step, Macro, Functions and more

Print Output

Reply
Occasional Contributor
Posts: 7

Print Output

[ Edited ]

I am able to print out the output with proc means, but how should I do by printing the same as the sample output as provided? The questions is :

Find out the mean maxpulse rate and mean weight for both female and male individuals in the fitness file. Use either concat, merge or combine of multiple data sets if necessary

 

The sample output:

Untitled.png

The Dataset is like:

fitnessdata.png

 

I have tried:


data work.mxpulseweight;
set orion.Fitness;
run;

proc means data=work.mxpulseweight;

class sex;
var weight maxpulse;
output out=mxpulseweight mean=mean;
run;

 

and I am able to get the output:

output.png

How should I do in order to get the same format as the sample output provide?

Super User
Posts: 19,772

Re: Print Output

Posted in reply to pailek1996

Your question, subject, and image don't quite make sense. 

 

What do you have, what do you want, and what have you tried?

 


pailek1996 wrote:

I am able to print out the output with proc means, but how should I do by printing the same as the sample output as provided? The questions is :

Find out the mean maxpulse rate and mean weight for both female and male individuals in the fitness file. Use either concat, merge or combine of multiple data sets if necessary

Untitled.png


 

Occasional Contributor
Posts: 7

Re: Print Output

I have updated the question post, sorry about that
Super User
Posts: 19,772

Re: Print Output

Posted in reply to pailek1996

Your expected output is unclear. If you need this is a sentence, then you woudl need to hard code those values in. 

 

You could use the dataset you create out of PROC MEANS and a data step to create the text and then use PROC PRINT to display the information. Customization takes work unfortunately.

Super User
Posts: 11,343

Re: Print Output

Posted in reply to pailek1996

I am going to guess that the idea is to take an output data set from proc means and then in a data step use the listed functions or operations to create text.

You would have to show us what you start with, i.e. the data set from proc means to get started.

Occasional Contributor
Posts: 7

Re: Print Output

I am sorry that i forgot to upload the data set image, i have a data set like this fitnessdata.png

I have tried :

data work.mxpulseweight;
set orion.Fitness;
run;

proc means data=work.mxpulseweight;

class sex;
var weight maxpulse;
output out=mxpulseweight mean=mean;
run;

 

and got output like this 

output.png

and how should I do in order to get the same format as the sample output

Super User
Posts: 11,343

Re: Print Output

Posted in reply to pailek1996

See if this gives you a hint:

proc format library=work;
value $sex
'F' = 'Female'
'M' = 'Male'
;
run;

data demo;
   set mxpulseweight;
   length text $ 100;
   text = catx(' ','Mean for',variable, put(sex,$sex.),'is',mean);
run;

the Catx is one example of what was intended for concatenation.

 

The (very minor) trick is to get the sex mismatched and variables linked and avaialbe on a single row. There are probably at least 5 realtively easy ways depending on the approach chosen. Since this sounds a lot like homework you'll learn more by at least attempting something and if you don't get the result then provide examples of what you did, the logic you were attempting to use and the result you actually received.

 

You might examine what your mxpulseweight data set looks like if you sort by varaible and then sex for one approach.

Ask a Question
Discussion stats
  • 6 replies
  • 260 views
  • 0 likes
  • 3 in conversation