Contributor
Posts: 22

# Data Logic

Hi All,

 ID Date Total Transaction Total Revenue Ref_Point 1200330 2/4/2014 65905 1656.45 65308.5 1200330 2/5/2014 67780 1846.36 65308.5 1200330 2/6/2014 68191 1744.44 65308.5 1200330 2/7/2014 65441 1900.14 65308.5 1200330 2/10/2014 51353 1315.1 65308.5 1200330 2/11/2014 21169 527.51 65308.5 1200330 2/12/2014 28738 759.81 65308.5 1200330 2/13/2014 61536 1831.35 65308.5 1200330 2/14/2014 56801 1283.84 65308.5 1200330 2/17/2014 1832 65.42 65308.5 1200330 2/18/2014 62752 1534.1 65308.5 1200330 2/19/2014 62889 1594.25 65308.5 1200330 2/20/2014 65176 1643.18 65308.5 1200330 2/21/2014 64904 1411.64 65308.5 1200330 2/24/2014 61411 1637.59 65308.5 1200330 2/25/2014 64187 1780.06 65308.5 1200330 2/26/2014 35090 1193.06 65308.5 1200330 2/27/2014 68947 1736.58 65308.5 1200330 2/28/2014 62097 1467.95 65308.5 1200330 3/3/2014 61661 1679.16 65308.5

1.   Flag out filter based on below condition:

If (“current transaction”  >= 60%  and of the ref_Point) and (%change in "Current Transaction" w.r.t "Previous Transaction" is >-50%) , keep it. Make this the new ref_point and set the following value the new “current”.

2.  Else, delete it and make the following value the new “current”.

Below is the code which i tried to execute .....

Looking for your help ASAP. Will be really thankful for u.

data output;

set Input_dataset;

/*ref_point_new=lag(DSQ_SUM);*/

if _n_=1 Then do ;ref_point_new=ref_point;end;

if _n_>1 Then DO ;

ref_point_new=lag(dsq_sum);

outlier=0;

end;

if dsq_sum >= .6*ref_point_new and ((dsq_sum-lag(dsq_sum))/lag(dsq_sum)) > -.5 then do;

outlier=0;

end;

else do outlier=1;

ref_point_new=dsq_sum;

end;

ref_point_new= lag(dsq_sum);

run;

proc print data=output;

Run;

Super User
Posts: 13,508

## Re: Data Logic

If (“current transaction”  >= 60%  and of the ref_Point) and (%change in "Current Transaction" w.r.t "Previous Transaction" is >-50%) , keep it. Make this the new ref_point and set the following value the new “current”.

Which "this"? Current transaction? Previous Transaction? 60% of current transaction? Something else?

Contributor
Posts: 22

## Re: Data Logic

Hi Ballardw

yes its 60% of Current transaction.

Super User
Posts: 13,508

## Re: Data Logic

Instead of lag use RETAIN

as in before your calculations:

Retain Ref_Point_new . ;

When you assign a new value to the Ref_Point_New variable it will be kept from iteration to iteration.

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