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