DATA Step, Macro, Functions and more

Hi Please suggest logic for the scenario

Frequent Contributor
Posts: 84

Hi Please suggest logic for the scenario

Hi Please suggest some logic.

I have a data set like customer name and month wise count. (In starting third month they have introduced one scheme i want to find out whether the scheme is impacting the next month counts i.e is there are any decrease or increase in mar apr month counts. I want to highlight those records.)


Custname Jan Feb Mar Apr

pvr 15 20 5 4

adlabs 20 30 40 50

imax 15 25 5 4

cinemax 29 35 7 6




like this i have one lakh customers and four months count.

I want to see based on Jan Feb count is there any trend in Mar Apr.

Suppose lets take PVR Jan feb it has increase but in march, apr it has decreased same as cinemax. Adlabs is increasing like that.

I want to highlight those customers. Any thoughts/logic. TIA

Trusted Advisor
Posts: 1,204

Re: Hi Please suggest logic for the scenario


Couple of things.

Only two months data would not be sufficient for a trend analysis. In order to highlight customers with increase/decrease counts just identify a logic like if sum of counts in Mar, Apr is greater than sum of counts in Jan, Feb then it would be considered as an increase otherwise a decrease. Without having such a logic it is hard to suggest a solution.

Super User
Posts: 17,819

Re: Hi Please suggest logic for the scenario

Data is too aggregated to suggest much as indicated above. 

Do you have data at a different level, i.e. weekly, daily?

Frequent Contributor
Posts: 84

Re: Hi Please suggest logic for the scenario

Hi Reeza,

Thanks for reply. The data is customer wise monthly count. How can we get trends in sas.

Super User
Posts: 17,819

Re: Hi Please suggest logic for the scenario

OK...its not a matter of trends in SAS its a matter of practice. 

The issue is that with only 4 data points the reliability of such an analysis is questionable.

For example:

Say, I have stock A and then look at the next two months.

Let's assume the probability of increase is 50/50.

So if I see it increase it the next 20 months the odds of that occurring was 0.5*0.5 = 1/4

If I see it decrease the odds were 1/4

To see it decrease one month/increase another month the odds are 50%. 

Because the odds are so high its hard to conclude anything from the data.

Hopefully that explains why you shouldn't do it.

Here's how you'd actually do it, because that's the actual question. This will give you the differences from months to month.

Then you need to decide what's a significant difference. Is it 1, if it changes from 5 to 4? Is it still 1 if it changes from 100 to 99?  Perhaps you should look at percent difference from month to month instead?

If you're testing a particular scheme implementation as initially requested you hopefully have a control group. This would mean some companies were exposed to the scheme and others not so you can try and tease out the actual effect. Then perhaps you want to group the categories together in some manner to see if the change is consistent across industries, i.e. if you can group companies by subject area such as: entertainment, health care or even products, experiences.  That might give you a way to find outliers, companies that don't perform the same as others in a group or groups that are affected by the scheme and others that aren't.

Hope this helps you get started.

data want;

set have;

array mths(4) Jan Feb Mar Apr;

array diff(3) Chg_feb chg_mar chg_apr;

do i=1 to 3;




Frequent Contributor
Posts: 84

Re: Hi Please suggest logic for the scenario


Thanks for detailed explanation. Smiley Happy

Ask a Question
Discussion stats
  • 5 replies
  • 3 in conversation