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 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 23 May 2006 18:11:52 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: How to use first. and last. ??
Comments: To: solouga5@rediffmail.com
In-Reply-To:  <20060523171020.25205.qmail@webmail72.rediffmail.com>
Content-Type: text/plain; format=flowed

Sa Polo ,

Seems to me that all the solutions you were originally given would only require a one second fix to do what you want:

Here is the one I posted earlier modified to do what you now ask.

data work.flag ; input Name:$8. Grade:$1. Points Flag:$1. ; cards ; Anthony A 10 Y Anthony A 10 N Mark B 10 Y Mark B 10 N Paul A 20 Y Raul A 10 Y ; run ;

data Flag ( drop = I TempFlag ) ; Length Flag $10 ;

do I = 1 by 1 until( Last.Points ) ; set Flag ( rename = ( Flag = TempFlag ) ) ; by name grade points;

Flag = Tranwrd( Strip( Compbl( Flag || TempFlag ) ) , ' ' , ',' );

end ;

run ;

Toby Dunn

From: sa polo <solouga5@REDIFFMAIL.COM> Reply-To: sa polo <solouga5@rediffmail.com> To: SAS-L@LISTSERV.UGA.EDU Subject: Re: How to use first. and last. ?? Date: Tue, 23 May 2006 17:10:20 -0000

Thanks All, actually i need to put a comma(,) in between Flags rather than concatenate . I tried modifying the code but have been unsucessfull.

Thanks, Sa Polo

On Tue, 23 May 2006 Andrew Howell wrote : > > Quoting ahowell@netspace.net.au: > > > > /* > > This should do the trick - assumes your data is in set1. > > N.B: Untested! > > */ > > proc sort data=set1 out=set2; > > by name grade points; > > run; > > data set3(drop=oldflag); > > set set2(rename=(flag=oldflag)); > >Oops - you also need to retain the flag value.. > > retain flag; > > > length flag $ 10 ; /* However long you want it */ > > by name grade points; > > > > if first.points then flag=" "; > > > > flag=cats(flag,oldflag); /* V9 */ > > flag=trim(flag)||trim(oldflag); /* V8 */ > > > > if last.points then output; > > run; > > > > > Quoting sa polo <solouga5@REDIFFMAIL.COM>: > > > > > > Hi All, > > > > > > This is my data: > > > > > > Name Grade Points Flag > > > Anthony A 10 Y > > > Anthony A 10 N > > > Mark B 10 Y > > > MArk B 10 N > > > Paul A 20 Y > > > Raul A 10 Y > > > > > > If the Name, Grade, Points are the same then > > > concatenate the Flags . > > > > > > Desired output > > > Name Grade Points Flag > > > Anthony A 10 YN > > > Mark B 10 YN > > > Paul A 20 Y > > > Raul A 10 Y > > > > > > All help is much appreciated as always. > > > Sa Polo > > > > > > > > ------------------------------------------------------------ > > This email was sent from Netspace Webmail: http://www.netspace.net.au > > > > > > > > > >------------------------------------------------------------ >This email was sent from Netspace Webmail: http://www.netspace.net.au


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