Hi, I am trying to convert below SAS code into SQL. Please let me know how to do that. I tried to convert it using lead, lag function but i am not getting desirable output. Please help me in converting this code. I am new to SAS.
data claim_counter;
set merged_clms;
by LINK_ID FIRST_NAME SPCLT_NM start_DT;
if first.FIRST_NAME then claim_counter = 0;
claim_counter+1;
run;
data fill_dt_ref;
set claim_counter;
by LINK_ID FIRST_NAME SPCLT_NM start_DT;
set claim_counter (firstobs= 2 keep=start_DT rename=(start_DT = next_start_dt))
claim_counter (obs=1 drop = _all_);
last_days= ifn(first.SPCLT_NM,(.),lag(DAYS));
last_dos= ifn(first.SPCLT_NM,(.),lag(adj_value/median_adj_value));
last_ex_dt= ifn(first.SPCLT_NM,(.),lag(ex_dt));
next_start_dt=ifn(last.SPCLT_NM,(.),next_start_dt);
run;
... View more