LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (September 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 18 Sep 2008 10:56:28 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: macro help!
Comments: To: tyralynn Frazier <tfrazi2@emory.edu>
In-Reply-To:  <200809181458.m8IAkrpB004403@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

Why are you including any of these inside datasteps? Macros don't properly exist as part of a dataset and thus shouldn't be in them. However, that's just a stylistic complaint. This may not be an error (... does flowbirthwt exist as a variable? If it does, you have a problem; but it probably simply doesn't exist.

In any event, your code should look like this:

%macro AgeSplit(varname=);

if (agegrup=1 and f&varname ge 1) then &varname.m=1; else if (agegrup=1 and g&varname ge 1) then &varname.m=1; else if (agegrup=1 and h&varname ge 1) then &varname.m=1;

else &varname.m=0; label &varname.m='1+&lowbirthwt 14-16'; %mend;

data work.macro_est1; set repeat.lowbirth; %agesplit(lowbirthwt); run;

You do not need to have a %let statement anywhere, because the macro variable 'varname' is set by passing it as a parameter in the macro call. You should create the macro prior to the datastep, not in it, though again that's mostly a style issue.

-Joe

On Thu, Sep 18, 2008 at 9:58 AM, tyralynn Frazier <tfrazi2@emory.edu> wrote:

> I included the %let in the data step like so, but I get log output that > says > > " Variable flowbirthwt is uninitialized" > > this is in blue, should I worry about this? If so then how do I account > for this in my code? (code below). > thanks, > tl > > > libname repeat "dataset"; > data work.tyra; > set repeat.lowbirth; > %let varname= lowbirthwt; > run; > > data work.macro_est1; > set work.tyra; > %macro AgeSplit(varname=); > > if (agegrup=1 and f&varname ge 1) then &varname.m=1; > else if (agegrup=1 and g&varname ge 1) then &varname.m=1; > else if (agegrup=1 and h&varname ge 1) then &varname.m=1; > > else &varname.m=0; > label &varname.m='1+&lowbirthwt 14-16'; > %mend; > %AgeSplit(varname=lowbirthwt); > run; >


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