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 (January 2003, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 28 Jan 2003 10:13:03 -0500
Reply-To:   "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Subject:   Re: Help with a loop
Comments:   To: "Mark T." <stats@CONSULTANT.COM>
Content-Type:   text/plain; charset="iso-8859-1"

Assuming, you have a good reason for what you are doing, here is a solution using call execute, obviating the need for a macro. The TRIM function can be safely excluded without any adverse effects. It exists only for cosmetic reasons. The log is a bit more readable.

data _null_ ; do i = 1 to 100 ; call execute ("proc sql ; create table temp"||trim(put(i+1,best.-l))|| " as select sum(supwtcor"||trim(put(i,best.-l))||") as supwtcor"||trim(put(i+1,best.-l))|| " from temp"||trim(put(i,best.-l))|| " group by psu order by psu ; quit;") ; end ; run ;

Good luck. __________________________ Venky Chakravarthy E-mail: swovcc@hotmail.com

-----Original Message----- From: Mark T. [mailto:stats@CONSULTANT.COM] Sent: Monday, January 27, 2003 2:50 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Help with a loop

How Can I do the following 100 times using a %do %to loop. Thanks.

PROC SQL; CREATE TABLE TEMP2 AS SELECT SUM(SUPWTCOR1) AS SUPWTCOR2 FROM TEMP1 GROUP BY PSU ORDER BY PSU; QUIT;

PROC SQL; CREATE TABLE TEMP3 AS SELECT SUM(SUPWTCOR2) AS SUPWTCOR3 FROM TEMP2 GROUP BY PSU ORDER BY PSU; QUIT;

PROC SQL; CREATE TABLE TEMP4 AS SELECT SUM(SUPWTCOR3) AS SUPWTCOR4 FROM TEMP3 GROUP BY PSU ORDER BY PSU; QUIT; . . . PROC SQL; CREATE TABLE TEMP101 AS SELECT SUM(SUPWTCOR100) AS SUPWTCOR101 FROM TEMP100 GROUP BY PSU ORDER BY PSU; QUIT;

LEGAL NOTICE Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.


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