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:
> create table my_table as
> select name
> from sashelp.class
> where name = "Alfred";
> data _null_;
> %let num_records = 0;
> set my_table nobs=nn end=last_record;
> if 0 then
> call symput('num_records', put(nn, best.));
> else if last_record then
> call symput('num_records', trim(left(_n_)));
>%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.