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 319
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.
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.