Date: Thu, 12 Feb 1998 16:53:36 GMT
Reply-To: Rex Chamberlain <chambreNOSPAM@MAIL.NORTHGRUM.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Rex Chamberlain <chambreNOSPAM@MAIL.NORTHGRUM.COM>
Organization: Northrop Grumman Corporation, Los Angeles, CA
Subject: Re: Newbie macro question
Roy,
I think you are looking for the following (see changes below):
PS: There is help in interactive sas, for instance, "help macro" that you
can use for documentation. At many installations you can start interactive
sas by typing sas on a command line,.
Note that I did not test the code and I did it off the top of my head.
Rex
Remove NOSPAM from reply address for email.
Roy Pardee <roy@u.arizona.edu> wrote in article
<34E26A9C.5A39@u.arizona.edu>...
> Greetings Gurus,
>
> I've got a made up dataset I need to print out in pieces & suspect
> that a macro would do the job gracefully. Unfortunately, I don't have
> the docs
> for the macro facility & my guesses as to how it should work are not
> panning out
> for me. Could one of you kindly point out what I need to do here?
>
> SAS didn't like the following:
>
%macro royprint; * to define the macro.;
> %do %nacb = 0 to 1 ;
> %do %EdBlock = 1 to 7 ;
> %do %AgeBlock = 1 to 5 ;
%do nacb = 0 %to 1;
%do edblock=1 %to 7;
%do ageblock =1 %to 5; * indentation is good practice. ;
> proc print ;
proc print data=roydata; * good practice;
> var Fig1--FailMain ;
> id scaled ;
> where nacb = &nacb and edblock = &EdBlock and ageblock =
&AgeBlock ;
> title "NACB=&nacb, EdBlock=&EdBlock, and AgeBlock=&AgeBlock"
;
run; * always good practice.;
> %end ;
> %end ;
%end ;
%mend royprint; * to end the definition;
%royprint; * to execute the macro.;
run;
>
> Specifically, SAS says:
>
> 160 %do %nacb = 0 to 1 ;
> ERROR: The %DO statement is not valid in open code.
>
> Do I need to move the %do statements to the very beginning of the
> program?
>
> Is the fact that I have dataset variables with the same names as macro
> variables a problem?
Nope.
>
> Bonus question: is there some way I can apply a user-defined format to a
> macro variable?
Yes - use the PUT function.
>
> A thousand thanks in advance!
>
> -Roy
>
>
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
> | Roy Pardee, J.D., M.A.
> | |
> | Psychology & Law Student | The difference between science
> and |
> | University of Arizona | advocacy is that scientists expose
> their |
> | | ideas to risk of
> falsification. |
> | (Writing from Seattle!)
> | |
> | roy@u.arizona.edu
> | |
>
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
>