Thanks, this looks good, I think. Trying it out, and I'm getting some errors. Here is the log (note that the variable names are somewhat different, and that there is a lot of code before (including the data import) which I've left out). I think if I fix line 462 it may work. Note that there may be some inconsistencies there, I had to change a couple of variable names and such due to posting publicly. Thanks! === data COMBINED_DATA; 455 set COMBINED_DATA; 456 temp_trans_date = mdy(trans_mo,01,trans_yr) ; 457 run; NOTE: There were 43528 observations read from the data set WORK.COMBINED_DATA. NOTE: The data set WORK.COMBINED_DATA has 43528 observations and 56 variables. NOTE: DATA statement used (Total process time): real time 0.07 seconds cpu time 0.08 seconds 458 459 proc sql; 460 create table tr_sum as select 461 CH_ID, temp_trans_date 462 sum(debit_amt) as tr_sum ___ 22 76 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=. ERROR 76-322: Syntax error, statement will be ignored. 463 from combined_data 464 group by CH_ID, temp_trans_date 465 order by CH_ID, temp_trans_date descending; NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements. 466 quit; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 467 468 data tr_flag; 469 set tr_sum; ERROR: File WORK.TR_SUM.DATA does not exist. 470 by CH_ID trans_mo descending; _ 22 ERROR 22-322: Syntax error, expecting one of the following: a name, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. 471 if first.CH_ID then flag1=0; else 472 if tr_sum > 1.5*(lag(tr_sum)) then flag1 = 1; 473 else flag1=0; 474 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.TR_FLAG may be incomplete. When this step was stopped there were 0 observations and 2 variables. WARNING: Data set WORK.TR_FLAG was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 475 476 proc sql; 477 create table trans_new as select 478 t.*, s.flag1 479 from COMBINED_DATA as t 480 left join tr_sum as s 481 on t.CH_ID = s.CH_ID and 482 t.trans_mo = s.trans_mo 483 order by trans_ID, CH_ID, trans_yr, trans_mo; ERROR: File WORK.TR_SUM.DATA does not exist. NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements. 483 ! /* adapt it to your needs */ 484 quit; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
... View more