Data Have ; Infile Cards ; Input sno dt Date9. ; Cards ; 1011 01jan2000 1012 02jan2000 1012 03jan2000 1012 04jan2000 1012 05jan2000 1012 06jan2000 1012 07jan2000 1013 03jan2000 1013 04jan2000 1013 05jan2000 1013 06jan2000 1013 07jan2000 ; Run ; Data Need ( Drop = Cnt ) ; Length NewVar $ 2 ; Set Have ; By Sno ; Retian Newvar ; If First.SNO Then Do ; Cnt + 1 ; NewVar = CatS( 'A' , Cnt ) ; End ; Run ; Proc Print Data = Need ; Format DT Date9. ; Run ; Toby Dunn If anything simply cannot go wrong, it will anyway. Murphys Law #2. The buddy system is essential to your survival; it gives the enemy somebody else to shoot at. Murphys Law # Tell a man there are 300 billion stars in the universe and he'll believe you. Tell him a bench has wet paint on it and he'll have to touch to be sure. Murphys Law #9 From: DP <adsingh78@GMAIL.COM> Reply-To: DP <adsingh78@GMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: SAS help needed Date: Fri, 8 Jun 2007 11:16:14 -0400 Hi, I need help in creating a dataset. I have sno dt 1011 01jan2000 1012 02jan2000 1012 03jan2000 1012 04jan2000 1012 05jan2000 1012 06jan2000 1012 07jan2000 1013 03jan2000 1013 04jan2000 1013 05jan2000 1013 06jan2000 1013 07jan2000 want: sno dt new_var 1011 01jan2000 a1 1012 02jan2000 a1 1012 03jan2000 a2 1012 04jan2000 a3 1012 05jan2000 a4 1012 06jan2000 a1 1012 07jan2000 a2 1013 03jan2000 a1 1013 04jan2000 a2 1013 05jan2000 a3 1013 06jan2000 a4 1013 07jan2000 a1 All the records are sorted by dt within sno and want to add a new variable in which 1st recore will have a1, 2nd will have a2, 3rd will have a3, 4th will have a4, 5th will have a1 again, 6th will have a2, and so on... The pattern repeats. Thanks in Advance. DP _________________________________________________________________ Picture this � share your photos and you could win big! http://www.GETREALPhotoContest.com?ocid=TXT_TAGHM&loc=us