Hi,
I want a sum of total media value grouped by probability
the data set is already sorted by me
data sas1;
set d.p3;
by Probability____;
if first.Total_Media_Value=1 then tot_budget=0;
tot_budget+Total_Media_Value;
if last.Total_Media_Value then output;
run;
log
Why not use proc means?
You can only use FIRST/LAST on variables that are included in your BY statement.
data sas2;
set d.p3;
by Probability____;
if first.Probability____=1 then tot_budget=0;
tot_budget+Total_Media_Value;
if last.Probability____ then output;
if Probability____=0 then delete;
run;
still getting the same error
log
Then you probably haven't sorted your data.
Sort your data.
Post the Proc sort and data step and the corresponding log that shows the error. Clearly SAS doesn't think it is.
All values must be ascending for the probability.
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.