```Date: Thu, 29 Sep 2011 21:53:39 -0400 Reply-To: Tom Abernathy Sender: "SAS(r) Discussion" From: Tom Abernathy Subject: Re: How to repeat multiple statements in a datastep? You can use transpose to do it with having the use macro language or other code generation techniques. data have; input ID abc1-abc4 cca1-cca4; cards; 1 5 5 4 4 3 3 2 2 2 3 3 4 4 5 6 3 4 ; proc transpose data=have out=v ; by id; run; data v; set v; team = substr(_name_,1,3); week = input(substr(_name_,4),best.); run; proc transpose data=v out=h prefix=week ; by id team ; id week ; var col1; run; data h ; set h ; _name_=trim(team)||'_r' ; ratio = sum(week1,week2)/sum(week3,week4) ; run; proc transpose data=h out=ratio (drop=_:) ; by id ; id _name_ ; var ratio ; run; data want ; merge have ratio ; by id; run; data _null_; set; put (id abc: cca:) (=) ; run; ID=1 abc1=5 abc2=5 abc3=4 abc4=4 abc_r=1.25 cca1=3 cca2=3 cca3=2 cca4=2 cca_r=1.5 ID=2 abc1=3 abc2=3 abc3=4 abc4=4 abc_r=0.75 cca1=5 cca2=6 cca3=3 cca4=4 cca_r=1.5714285714 ```

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