Hi Guys, I want to rank my my data within groups, so I used lag function in my codes. But it seems this function does not work. I'm wondering why lag1(mylabel) is missing when _n_=2. Anyone could help me out? Thanks. Mike data cake; input Name $ 1-10 type 12-13 Taste 15-16; datalines; Davis 1 84 Orlando 1 80 Ramey 1 72 Roe 2 75 Sanders 2 79 Simms 2 77 Strickland 2 79 ;run; proc sort data=cake; by type taste;run; data a; set cake; by type taste; if type=lag1(type) then mylabel=1+lag1(mylabel); else mylabel=1; if _n_=1 then mylabel=1; run;
... View more