Question 1 --In i my data i have the columns - probability and Budget.
I want to group the data by probability and get sum of budget = Total budget for each probability level.
I also want a variable named foretasted Budget which which has product of total budget and probability
how do i get this with proc means.?
My half written code-
proc means data = c1.od noprint nonobs;
var Total_Media_Value ;
class _probability___/ descending;
output out=data (drop = _TYPE_ _FREQ_)
sum = Total_Budget
n= num_of_optys;
run;Question 2-- in the output i am getting a row which gives me total of columns. I want to give that row a name - Total , how do i do that?
eg- my result looks like this -
probability total budget num
1 . 3200531 361
2 100 68100 7
3 90 56000 4
4 70 23200 8
5 50 156500 18
6 30 112000 5
7 10 2784731 319Since you re-posted Question 2 separately, I'll give you an answer to just Question 1 here.
You're asking to calculate a new variable, and add it to an existing data set. PROC MEANS won't do that, but a DATA step can do that easily. For example:
data want;
set data;
forecasted_budget = total_budget * _probability___ ;
run;
It's not clear if you want that as the result, or if you should be dividing by 100. But the formula is up to you.
Since you re-posted Question 2 separately, I'll give you an answer to just Question 1 here.
You're asking to calculate a new variable, and add it to an existing data set. PROC MEANS won't do that, but a DATA step can do that easily. For example:
data want;
set data;
forecasted_budget = total_budget * _probability___ ;
run;
It's not clear if you want that as the result, or if you should be dividing by 100. But the formula is up to you.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.