Contributor
Posts: 50

# Weighting Variables help

I have a sample of Sales data over the course of 1 year(separated into 2, 6 month intervals) which reports the # of Sales (Count) by Vendor (3 unique vendors).

What I'm trying to figure out is, for each vendor, do their sales vary based on the period. Each of the 3 vendors varies in the amount of sales so I am hoping to find a way to weight the sales by vendor so I can eventually compare each on a "level playing-field".

For example the difference between period 1 and 2 for Vendor 1 may have a difference of 5 sales, where the same time frame for Vendor 3 might be 25 , but as a % overall this would be an equivalent difference...I hope that makes sense...

I've prepared a data-set to show how my data appears:

data a;

input vendor period count  @@;

datalines;

1 1 5

1 1 10

1 2 7

1 2 11

2 1 20

2 1 25

2 2 18

2 2 26

3 1 70

3 1 75

3 2 100

3 2 150

;

run;

Thanks in advance for the help!

Super User
Posts: 23,663

## Re: Weighting Variables help

Standardize the rates perhaps and analyze the percent change instead?

Occasional Contributor
Posts: 17

## Re: Weighting Variables help

Hello,

All you have to do is appropriately dealing with the lag function across different groups (in this case, vendor).

Try this:

data a;

input vendor period count;

datalines;

1 1 5

1 1 10

1 2 7

1 2 11

2 1 20

2 1 25

2 2 18

2 2 26

3 1 70

3 1 75

3 2 100

3 2 150

;

run;

/* half-year growth */

data b(drop=countlag);

set a;

by vendor; *can skip proc sort if data is already sorted;

countlag=lag(count); *record lagged value of sales count;

if first.vendor then countlag=.; * lag value is meaningless across vendors;

growth=count/countlag-1;

run;

Discussion stats
• 2 replies
• 175 views
• 0 likes
• 3 in conversation