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 (April 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
              Peg..
Comments: To: "camherst@MISER.UMASS.EDU" <camherst@MISER.UMASS.EDU>
Content-Type: text/plain

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 ; End ; Run ;

Ed

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 mailto:EdHeaton@Westat.com http://www.Westat.com

-----Original Message----- From: Christopher Amherst [mailto:camherst@MISER.UMASS.EDU] Sent: Thursday, April 15, 2004 11:53 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Data step within a data step? - continuation of SAS & Square Peg..

Here's a few snips of code: %MACRO tally (tarray); DATA _NULL_; SET ballots; &tarray(vote1)+BallotWt; RUN;

%MEND tally;

-- Main program -- DATA _NULL_; SET summary; ARRAY tallys (13) tally1-tally13;

%tally(tallys);

RUN

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 have 3 data sets.

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 manipulation.

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?)

OR

What would be a better solution to the problem?


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