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 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 11 Jan 2006 18:46:39 -0500
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: Loop through data sets
Comments: To: jjj912@YAHOO.COM

I'm later than everyone else but, since I had written the following code before being called upon to accomplish one of those typical household tasks, I'm including it for your review.

However, before doing so, I should mention that I agree with the advice you have already been given concerning other ways to consider in accomplishing your task:

data filelist; input filename $; cards; A B C ; run; data A; do GAMMA = 11 to 15; output; end; run; data B; do GAMMA = 11 to 20; output; end; run; data C; do GAMMA = 13 to 25; output; end; run; proc sql noprint ; select filename into : FNAMES separated by " " from filelist ; quit ; %macro loop ; %do i = 1 %to &SQLObs; data %scan(&FNAMES,&i)new; set %scan(&FNAMES,&i); if GAMMA eq 13 then GAMMA=99; run; %end; %mend Loop ; %loop

Art --------- On Wed, 11 Jan 2006 14:28:29 -0800, jjj912@YAHOO.COM wrote:

>How do I loop through several existing datasets, perform an operation >on each, and then save the modified dataset as a new dataset? > >Here's some code that illustrates what I want to accomplish: > >data ; > do i = 1 to 3; /* Loop through existing datsets */ > set old[i]; /* Contains a list of old datasets */ > if some_variable >0 then > do > some_variable= 123; /* perform an operation */ > output new[i]; /* Output data to a new dataset */ > end; > end; >run; > >Thanks,


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