BookmarkSubscribeRSS Feed
ST85
Calcite | Level 5

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

 

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

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?

ST85
Calcite | Level 5

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

Reeza
Super User

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.

ST85
Calcite | Level 5

I do not have a continous series. I need to calculate this by each brand.

Reeza
Super User

Did none of the solutions in the blog work for you?

If not, please explain how.

ballardw
Super User

Show what your desired output for the example data should look like.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1757 views
  • 1 like
  • 4 in conversation