LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sat, 23 May 2009 10:35:27 -0400
Reply-To:   Randy <randistan69@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Randy <randistan69@HOTMAIL.COM>
Subject:   Flagging Last observations of Groups

Dear All:

Here is my data set.

VarA VarB A 11 A 12 A 16 A 10.5 B 4 A 6 A 8 A 9 B 11.5 B 12.5 B 3 A 12 A 13

I want to construct to variables VarC and VarD which are flags of the last observations of the groups of VarA

VarA VarB VarC VarD A 11 0 0 A 12 0 0 A 16 0 0 A 10.5 1 0 B 4 0 1 A 6 0 0 A 8 0 0 A 9 1 0 B 11.5 0 0 B 12.5 0 0 B 3 0 1 A 12 0 0 A 13 1 0

I wrote the following:

data have; set have; if VarA = A and last.VarA then do VarC = 1 ; end; else do VarC = 0; end; if VarA = B and last.VarB then then do VarD = 1 ; end; else do VarD = 0; end; run;

What mistake am I making? Randy


Back to: Top of message | Previous page | Main SAS-L page