BookmarkSubscribeRSS Feed
SasPro
Calcite | Level 5

Hi All,

IDDateTotal TransactionTotal RevenueRef_Point
12003302/4/2014659051656.4565308.5
12003302/5/2014677801846.3665308.5
12003302/6/2014681911744.4465308.5
12003302/7/2014654411900.1465308.5
12003302/10/2014513531315.165308.5
12003302/11/201421169527.5165308.5
12003302/12/201428738759.8165308.5
12003302/13/2014615361831.3565308.5
12003302/14/2014568011283.8465308.5
12003302/17/2014183265.4265308.5
12003302/18/2014627521534.165308.5
12003302/19/2014628891594.2565308.5
12003302/20/2014651761643.1865308.5
12003302/21/2014649041411.6465308.5
12003302/24/2014614111637.5965308.5
12003302/25/2014641871780.0665308.5
12003302/26/2014350901193.0665308.5
12003302/27/2014689471736.5865308.5
12003302/28/2014620971467.9565308.5
12003303/3/2014616611679.1665308.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;

3 REPLIES 3
ballardw
Super User

     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?

SasPro
Calcite | Level 5

Hi Ballardw

yes its 60% of Current transaction.

ballardw
Super User

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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 3 replies
  • 1556 views
  • 0 likes
  • 2 in conversation