DATA Step, Macro, Functions and more

How to reuse the calculated mean value of PROC for further calculation?

Accepted Solution Solved
Reply
Contributor
Posts: 26
Accepted Solution

How to reuse the calculated mean value of PROC for further calculation?

I have calculated the mean of a variable using MEAN proc, now I want to use mean value for further calculation. Please help me to reuse or save the calculated mean value for further use.

 

data test; 
input x ; 
cards; 
100 
200 
300 
; 
run; 

proc means data=test; 
var x; 

run; 

Accepted Solutions
Solution
‎04-19-2017 11:47 AM
Super User
Posts: 17,823

Re: How to reuse the calculated mean value of PROC for further calculation?


All Replies
Super User
Super User
Posts: 7,401

Re: How to reuse the calculated mean value of PROC for further calculation?

You can output to dataset from that in a variety of ways (the manual is your friend), you could do;

proc means data=test; 
  var x; 
  output out=want mean=mean;
run; 
Contributor
Posts: 26

Re: How to reuse the calculated mean value of PROC for further calculation?

Thanks your solution also worked for me.

Solution
‎04-19-2017 11:47 AM
Super User
Posts: 17,823

Re: How to reuse the calculated mean value of PROC for further calculation?

Here's two ways of accomplishing this solution. 

 

https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 114 views
  • 2 likes
  • 3 in conversation