Date: Thu, 15 Apr 2004 13:27:22 -0400
Reply-To: Ed Heaton <EdHeaton@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ed Heaton <EdHeaton@WESTAT.COM>
Subject: Re: Data step within a data step? - continuation of SAS & Square
Chris (I assume that's your name; you didn't identify yourself!);
A DATA step is essentially an implied DO loop with a loop counter (_N_)
and a method of exiting the loop. The loop driver here is the SET
statement and your implied loop ends with an attempt to read past the
end of the SUMMARY data set.
Now, you can - in essence - embed another DATA step in your DATA step by
writing an explicit loop somewhat as follows. Of course, I really don't
know what you're trying to do so this code is only meant as an idea.
Data _null_ ;
Set summary ;
Array tallys [*] tally1-tally13 ;
Do until endOfBallots ;
Set ballots end=endOfBallots ;
tallys[vote1] + BallotWt ;
Edward Heaton, SAS Senior Systems Analyst,
Westat (An Employee-Owned Research Corporation),
1600 Research Boulevard, RW-3541, Rockville, MD 20850-3195
Voice: (301) 610-4818 Fax: (301) 610-5128
From: Christopher Amherst [mailto:camherst@MISER.UMASS.EDU]
Sent: Thursday, April 15, 2004 11:53 AM
Subject: Data step within a data step? - continuation of SAS & Square Peg..
Here's a few snips of code:
%MACRO tally (tarray);
-- Main program --
ARRAY tallys (13) tally1-tally13;
The problem (outside of the fact that I know the snippage above doesn't work
(the call to the macro returns an 'unreferenced array' error.) is that I
What I need to do is in the main program -
Pass an array or other piece of relevant data to these other data sets, have
the array set in these data sets, and return to the main data set for
So the questions are:
Can I do something like %GLOBAL ARRAY tallys (13) tally1-tally13;?
(And if so, how do I reference it in the main program and other macros?)
What would be a better solution to the problem?