turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- How to make a new variable using ouput value

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-08-2017 04:41 PM

Hi,

I used proc means to calculate mean values of a variable. And now I want to use the mean values to calculate other variables.

How can I make the mean values a new variable in SAS statement?

Thanks!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to leahcho

12-08-2017 05:28 PM

It will help to provide an example of what you are doing for some example start data, the proc means code and how you want to actually use the resulting values from proc means.

Proc means supports an output statement to create a data set with the requested statistics.

Or learn about ODS output to capture data from table output.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

12-08-2017 05:40 PM

Thanks

So I used

proc means data=have;

var new;

run;

Then in the output, I have

Variable n mean std error

new 1176 3.6 0.97

Then I want to use the mean value of 3.6 to calculate another variable called MP;

MP=mean* proportion

this is possible to do?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to leahcho

12-08-2017 06:23 PM

Where is "proportion" from? If it is in your data set HAVE then better is to show us what the data set looks like.

Best is to provide data step code to create your data set and an example of the result(s).

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to leahcho

12-08-2017 05:41 PM

I would guess this is what you are referring to:

proc mean data=have1 noprint;

var amount;

output out=stats mean=mean_amount;

run;

data want;

set have2;

if _n_=1 then set stats (keep=mean_amount);

*** do some calculations here;

run;

The data set STATS has one observation, which includes the variable MEAN_AMOUNT. Its value will become part of every observation in the data set WANT.