Hi,
I have a dataset like presented below:
Brands Date Sales QTY %Delivery
Adidas 5/15/2017 14000 19 45
Adidas 5/15/2017 1000 12 20
Adidas 5/16/2017 10000 5 35
Adidas 5/17/2017 6000 8 20
Adidas 5/18/2017 8000 17 18
Nike 5/16/2017 6000 8 12
Nike 5/17/2017 8000 13 10
Nike 5/18/2017 8000 13 11
-
-
I have data like above for different brands and their delivery percentage. The problem is I would like to loop through all the 100 brands and create a flag for each brand where %Delivery (last column) is 40% more than the last 5 day average.
Thank you
Do you want as many records as in your current dataset with a 0/1 flag or do you want 1 record for each brand?
I want one record for each brand. The business problem is if current %delivery is more than last five day's average then create a flag 1 else zero. and then output it
http://blogs.sas.com/content/iml/2016/01/27/moving-average-in-sas.html
If you can assume that you have a continuous series, the best solutions are above.
Otherwise you need to first figure out how to deal with breaks in your data.
I do not have a continous series. I need to calculate this by each brand.
Did none of the solutions in the blog work for you?
If not, please explain how.
Show what your desired output for the example data should look like.
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.