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 (May 2003, 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 May 2003 16:12:10 -0400
Reply-To:     Ed Heaton <EdHeaton@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
Comments:     To: Nagakumar Sridhar <nsridhar@atherogenics.com>
From:         Ed Heaton <EdHeaton@WESTAT.COM>
Subject:      Re: Help with a macro
Comments: To: SAS-L@LISTSERV.VT.EDU
Content-Type: text/plain; charset="iso-8859-1"

Okay, let's define them.

%let trt11 = 101 ; %let trt12 = 102 ; %let trt13 = 102 ; %let trt1 = 21 ; %let trt2 = 22 ; %let trt3 = 23 ; %macro sqldata; data sqlman; retain total total1 0; %do i=1 %to 3; total1=total1 + &&&trt1&i.; total=total+&&&trt&i.; output; %end; run; %mend; %sqldata

Now we get

NOTE: Line generated by the macro variable "I". 1 &211

The problem is too many ampersands. Try

%macro sqldata; data sqlman; retain total total1 0; %do i=1 %to 3; total1=total1 + &&trt1&i.; total=total+&&trt&i.; output; %end; run; %mend; %sqldata

Ed

Edward Heaton, Senior Systems Analyst, Westat (An Employee-Owned Research Corporation), 1600 Research Boulevard, Room 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: Nagakumar Sridhar [mailto:nsridhar@atherogenics.com] Sent: Thursday, May 15, 2003 3:54 PM To: Ed Heaton Subject: Re: Help with a macro

Ed:

They are defined in an sql just prior to this where I take the count of all ae's for the 3 treatment groups and put them into trt1-trt3 and the count of visits to trt11-trt13.

I should have included that.

Regards Kumar ----- Original Message ----- From: "Ed Heaton" <EdHeaton@westat.com> To: "'Nagakumar Sridhar'" <nsridhar@ATHEROGENICS.COM> Sent: Thursday, May 15, 2003 2:48 PM Subject: RE: Help with a macro

> Kumar, > > You are looking for macro variables called trt11, trt12, trt13, trt1, trt2, > and trt3. You don't have such macro variables; where are they defined? > > Ed > > -----Original Message----- > From: Nagakumar Sridhar [mailto:nsridhar@ATHEROGENICS.COM] > Sent: Thursday, May 15, 2003 1:49 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Help with a macro > > > I have written a macro: > > > %macro sqldata; > data sqlman; > retain total total1 0; > %do i=1 %to 3; > total1=total1 + &&&trt1&i.; > total=total+&&&trt&i.; > output; > %end; > run; > %mend; > > %sqldata; > > > which is supposed to go thro' 3 iterations (the 4th one will fail) and pick > up the values for trt1. It is not working when the value of trt3 is zero > (returns an error that says it was unable to resolve trt3). > > > > I'd appreciate any help in this regard. > > > > Kumar Sridhar


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