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 (September 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 12 Sep 2009 19:53:35 -0700
Reply-To:     Patrick <patrick.matter@GMX.CH>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Patrick <patrick.matter@GMX.CH>
Organization: http://groups.google.com
Subject:      Re: Counter/Loop
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

Hi ash Have a look at the code below. If you have to sort your dataset: Be careful not to "destroy" the sequence of transactions on the same day (for the same account and fund). Hope you have in reality some additional key or that the date field is datetime. HTH Patrick

data have; input AcctNo $ FundNo Date:yymmdd8. Amount Trans:$10.; format date ddmmyy10. ; trans=strip(trans); datalines; A1 322 20080415 -2000 Redemption 0 A1 432 20080423 -4000 Redemption 0 A1 432 20080424 -4767 Redemption 0 A1 432 20080502 5000 Purchase 0.5 A1 432 20080603 -5166 Redemption 1 A1 432 20080715 5000 Purchase 1.5 A1 432 20080716 2500 Purchase 1.5 A1 432 20080718 2500 Purchase 1.5 A1 432 20080724 2000 Purchase 1.5 A1 1944 20080715 1000 Purchase 0 A1 1944 20080814 -1000 Redemption 0.5 A1 1944 20080819 -2933 Redemption 0.5 A2 322 20080404 -6350 Redemption 0 A2 322 20080404 -15482 Redemption 0 A2 322 20080509 5000 Purchase 0.5 A2 322 20080523 5000 Purchase 0.5 A2 322 20080606 -10000 Redemption 1 A2 322 20080609 -5731 Redemption 1 A2 322 20080620 5000 Purchase 1.5 A2 322 20080623 -5127 Redemption 2 A2 322 20080703 5000 Purchase 2.5 A2 444 20080513 3009 Purchase 0 A2 444 20080725 -2887 Redemption 0.5 run;

data want; set have; by AcctNo FundNo Date; if trans ne lag(trans) then Trip+0.5; if first.FundNo then Trip=0; run; proc print; run;


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