Date: Mon, 12 Jan 1998 13:48:34 -0500
Reply-To: "Abelson, Robert" <RobertA@MOCR.OAPI.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: "Abelson, Robert" <RobertA@MOCR.OAPI.COM>
Subject: Re: Help with Macro
Content-Type: text/plain
Ashok,
I haven't tested this, so if it doesn't work I will fax you back your
dollar (if you give me your fax number). But try doing your macro like
this:
%macro myreg;
%do j=1 %to 50;
proc reg data=a;
model y=x&j;
run;
%end;
%mend;
%myreg;
This should do what you want.
Bob Abelson
Otsuka America Pharmaceutical Inc.
> -----Original Message-----
> From: A. Natarajan [SMTP:anataraj@UCI.EDU]
> Sent: Friday, January 09, 1998 9:41 PM
> To: SAS-L@UGA.CC.UGA.EDU
> Subject: Help with Macro
>
> I have never understood macros in SAS, and therefore, I am not
> surprised why macros never work for me - here is my problem.
>
> I want to do 50 univariate regressions, and want to implement a macro
> solution. I thought of:
>
> data a ;
> infile 'a.dat' ;
> input y x1-x50 ;
> run ;
>
> %macro myreg (j);
> proc reg data=a ;
> model y = x{j} ;
> run ;
> %mend ;
>
> data _NULL_ ;
> array x{50} x1-x50 ;
> do j = 1 to 50 ;
> %myreg(j) ;
> end ;
>
> SAS tells me that j is unrecognized. There must be a better solution
> that the "brute force" approach of putting all 50 regressions! I'd
> appreciate a lesson in macros.
>
> Ashok
|