Need help:) ID JAHR LAGE tmp lagenew 1 2006 1 1 . 1 2007 2 2 1 2 2007 2 2 . 2 2008 2 2 . 2 2009 2 2 . 3 2007 4 4 . 3 2008 5 5 1 3 2009 5 5 1 4 2008 1 1 . 4 2009 1 1 . 5 2008 5 5 . 5 2009 5 5 1 5 2010 4 4 1 6 2008 3 3 . 6 2009 3 3 1 6 2010 3 3 1 i have a problem with the retain statement. I want to know if a ID changed the variable "LAGE" and if it increase or deacrease. It is working for the few first IDs but then SAS does somthing i don't understand. The following is what i was thinking will work, but it does not. proc sort data = Mop.increase; by id jahr; run; data hh; set Mop.increase; by id; retain tmp; if first.id then tmp = lage; if tmp > lage then lagenew=2; if tmp < lage then lagenew=1; tmp=lage; run; thanks for your help:-)
... View more