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 (December 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 18 Dec 2002 11:01:28 -0500
Reply-To:     "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Subject:      Re: Playtime: local and global macro variables
Comments: cc: "sandrun@PRODIGY.NET" <sandrun@PRODIGY.NET>
Content-Type: text/plain

fwiw: runs same in V9.00 (TS M0) Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov

> From: Ed C. [mailto:sandrun@PRODIGY.NET] > Here is fun code to test basic understanding of macro > variables. I needed reminding about the concept of > inheritance (is that the right word?). Ran it under Windows SAS v8.2. > > Hope this informs or entertains. > Ed C > > --------code------------------- > --------code------------------- > --------code------------------- > > *---------------------------------------------------------------*; > * program: test_localglobal.sas *; > * author: ed cabanero (sandrun@prodigy.net) *; > * date: 17Dec2002 *; > * objective: verify understanding of inherited macro variables *; > * input/output required: *; > * none *; > * description: *; > * each macro calls the macro just above it and *; > * displays information about macro variables *; > * available for use within each call. *; > *---------------------------------------------------------------*; > > %macro calledf; > > %put Step 4. Value from calledt is test3 = &test3; > > %global test4; > %let test4=final; > > %put; > %put Section 2. Return nth call to top level macro; > %put %nrstr(Step 4. calledf -->); > %put _user_; > > %mend; > > %macro calledt; > > %put Step 3. Value from called is test2 = &test2; > > %local test3a; > %let test3=symbols; > %let test3a=symbolsyeah; > > %calledf; > > %put %nrstr(Step 3. calledt -->); > %put _user_; > > %mend; > > %macro called; > > %put Step 2. Value from caller is test1 = &test1; > > %let test2=123.45; > > %calledt; > > %put %nrstr(Step 2. called -->); > %put _user_; > > %mend; > > > %macro caller; > > %put; > %put Section 1. Begin top level macro to nth call; > %put Step 1. Start the chain; > > %let test1=be a character string; > > %called; > > %put %nrstr(Step 1. caller -->); > %put _user_; > > %mend; > > %caller; > > V8.2 > --------log-------------------- > --------log-------------------- > > Section 1. Begin top level macro to nth call > Step 1. Start the chain > Step 2. Value from caller is test1 = be a character string > Step 3. Value from called is test2 = 123.45 > Step 4. Value from calledt is test3 = symbols > > Section 2. Return nth call to top level macro > Step 4. calledf --> > CALLEDT TEST3 symbols > CALLEDT TEST3A symbolsyeah > CALLED TEST2 123.45 > CALLER TEST1 be a character string > GLOBAL TEST4 final > Step 3. calledt --> > CALLEDT TEST3 symbols > CALLEDT TEST3A symbolsyeah > CALLED TEST2 123.45 > CALLER TEST1 be a character string > GLOBAL TEST4 final > Step 2. called --> > CALLED TEST2 123.45 > CALLER TEST1 be a character string > GLOBAL TEST4 final > Step 1. caller --> > CALLER TEST1 be a character string > GLOBAL TEST4 final


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