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 (October 2003, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 14 Oct 2003 14:59:47 -0400
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: macro variable not resolving

As others have pointed out, there is no macro named "num_records". There is a macrovariable having that name. So change the percent sign (%) to an ampersand (&) and declare the macrovariable global.

Also, you should be aware that the construct

if 0 then do; ... end;

will never be executed, since the condition is a constant which evaluates to FALSE. Sometimes people code things like this solely for the sake of compile-time effects, but I see no such purpose here.

On Mon, 13 Oct 2003 02:36:49 -0700, Rune Runnestoe <rune@FASTLANE.NO> wrote:

>What is wrong with this code: > >proc sql; > create table my_table as > select name > from sashelp.class > where name = "Alfred"; >run; > >%macro number_of_records; > data _null_; > %let num_records = 0; > set my_table nobs=nn end=last_record; > if 0 then > do; > call symput('num_records', put(nn, best.)); > end; > else if last_record then > do; > call symput('num_records', trim(left(_n_))); > end; > run; > >%mend; >%number_of_records; >%put The number of records is: %num_records; > > >I get the this error message in the log: > >13747 %put The number of records is: %num_records; >WARNING: Apparent invocation of macro NUM_RECORDS not resolved. >The number of records is: %num_records > > > >It seems to me like the macro variable NUM_RECORDS is not resolved, >and when I reference it further in the program, I get error messages. > > >Regards > >Rune Runnestoe


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