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 (March 2003, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 22 Mar 2003 19:25:57 +0000
Reply-To:     sashole@bellsouth.net
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Dorfman <paul_dorfman@HOTMAIL.COM>
Subject:      Re: Data step question
Comments: To: J.Groeneveld@ITGROUPS.COM
Content-Type: text/plain; format=flowed

>From: Jim Groeneveld <J.Groeneveld@ITGROUPS.COM> > >Hi Tomasz, > >Welcome, you apparently are a beginning SAS user. Your problem is very >basic >and simple: > >DATA Table; > VarA = 20; > DO _I_ = 1 TO 100; > OUTPUT; > END; >RUN;

Jim,

I may be wrong (then my apologies and disregard the rest), but I suspect that you are uisng _I_ because you think it is dropped automatically. In reality, it occurs only if an implicitly subscripted array has been declared in the Data step with the iterator variable _i_ defined *implicitly*. Any iterator variable defined explicitly, including _i_, does not get dropped. Run and compare:

92 data a ; 93 do _i_ = 1 to 3 ; output ; end ; 94 run ; NOTE: The data set WORK.A has 3 observations and 1 variables.

95 data a ( drop = a: ) ; 96 array aa a1-a3 ; 97 do _i_ = 1 to 3 ; output ; end ; 98 run ; NOTE: The data set WORK.A has 3 observations and 0 variables.

99 data a ( drop = a: ) ; 100 array aa (_i_) a1-a3 ; 101 do _i_ = 1 to 3 ; output ; end ; 102 run ; NOTE: The data set WORK.A has 3 observations and 1 variables.

103 data a ( drop = a: ) ; 104 array aa (_j_) a1-a3 ; 105 do _j_ = 1 to 3 ; output ; end ; 106 run ; NOTE: The data set WORK.A has 3 observations and 1 variables.

Note the conditions under which _i_ does get dropped. Hence, from the standpoint of utilizing auto-dropped idle stuff _n_ or _iorc_ are better candidates. Some folks recommend to avoid moving stuff to automatic variables altogether. The advice is perhaps sound, although I myself am guilty as sin in not following it, as many here have seen over the years. On the other hand, I have never seen any harm coming from reusing idle self-exterminating stuff, and would even argue that it is impossible to avoid assigning values to all automatics because, for one thing, there clearly exist situations when _iorc_ and _error_ need to be reset.

Kind regards, ---------------- Paul M. Dorfman Jacksonville, FL ----------------

_________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail


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