BookmarkSubscribeRSS Feed
pailek1996
Fluorite | Level 6

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?

6 REPLIES 6
Reeza
Super User

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


 

pailek1996
Fluorite | Level 6
I have updated the question post, sorry about that
Reeza
Super User

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.

ballardw
Super User

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.

pailek1996
Fluorite | Level 6

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

ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 6 replies
  • 1037 views
  • 0 likes
  • 3 in conversation