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.

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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