| Date: | Tue, 28 Feb 2006 08:35:02 -0600 |
| Reply-To: | Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM> |
| Subject: | Re: Macro Help Needed. |
|
| Content-Type: | text/plain; charset=US-ASCII |
Steve:
Your statements below give you trouble:
call symput('height1',height);
%put 'height1='&height1;
The first call symput is executed when the data step encounters run
statement and "%put 'height1='&height1;" tries to use the macro value
before it is assigned. When you run the second time the macro value
height1 exists and hence you may run without error.
I just gave you the cause. Without knowing what your intention, I
cannot give you further help.
J S Huang
1-515-557-3987
fax 1-515-557-2422
>>> "Xiao, Steven" <sxiao@SFWMD.GOV> 2/28/2006 8:26:19 AM >>>
SAS-L'ers -
To output the correct answer, I always have to run this Macro twice or
more, whenever I invoke SAS and run this code, it gives me the error
message as attached below, but I run it again, the correct answer will
pop up, does anybody can help me out why and how to make it corrected?
Great thanks Env: WinXP with SAS-8
Steven
=========== Code ==============
%macro t();
data tmp;
set sashelp.class nobs=nobs;
if _N_=nobs
then
do;
call symput('height1',height);
%put 'height1='&height1;
put 'N=' _N_;
put 'nobs=' nobs;
end;
run;
quit;
%mend t;
%t;
=========== Code Finish ==============
============ Error when the 1st run ==============
1 %macro t();
2 data tmp;
3 set sashelp.class nobs=nobs;
4 if _N_=nobs
5 then
6 do;
7 call symput('height1',height);
8 %put 'height1='&height1;
9 put 'N=' _N_;
10 put 'nobs=' nobs;
11 end;
12 run;
13 quit;
14 %mend t;
15 %t;
WARNING: Apparent symbolic reference HEIGHT1 not resolved.
'height1='&height1
NOTE: Numeric values have been converted to character values at the
places given by:
(Line):(Column).
1:96
N=19
nobs=19
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.TMP has 19 observations and 5 variables.
NOTE: DATA statement used:
real time 0.10 seconds
cpu time 0.10 seconds
================= Error Finish ====================
|