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 (January 1998, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: "A. Natarajan" <anataraj@UCI.EDU>
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


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