我运行后,得到的结果为:
1 %let n=10; 2 %macro limit; 3 %do a=1 %to 5; 4 %if %a=1 %then %do; %let smplsize=10; %end; 5 %if %a=2 %then %do; %let smplsize=50; %end; 6 %if %a=3 %then %do; %let smplsize=100; %end; 7 %if %a=4 %then %do; %let smplsize=500; %end; 8 %if %a=5 %then %do; %let smplsize=1000; %end; 9 %do b=1 %to &n; 10 data dat; 11 do i=1 to &smplsize; 12 x=ranuni(0); 13 x=-0.59+(x**0.0355-(1-x)**0.1179)/0.1206; 14 output; 15 end;run; 16 proc means data=dat; 17 var x; 18 output out=dat1 mean=meanx;run; 19 data dat2; 20 set dat1; 21 smplsize=&smplsize; 22 keep smplsize meanx; 23 %end; 24 %end; 25 %mend limit; 26 %limit;run; WARNING: Apparent invocation of macro A not resolved. WARNING: Apparent invocation of macro A not resolved. WARNING: Apparent invocation of macro A not resolved. WARNING: Apparent invocation of macro A not resolved. WARNING: Apparent invocation of macro A not resolved. NOTE: Line generated by the invoked macro "LIMIT". 26 data dat; do i=1 to &smplsize; x=ranuni(0); x=-0.59+(x**0.0355-(1-x)**0.1179)/0.1206; - 22 26 ! output; end;run; proc means data=dat; var x; output out=dat1 mean=meanx;run; data dat2; 26 ! set dat1; smplsize=&smplsize; keep smplsize meanx; WARNING: Apparent symbolic reference SMPLSIZE not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, INPUT, PUT.
NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DAT may be incomplete. When this step was stopped there were 0 observations and 3 variables. NOTE: DATA statement used: real time 0.28 seconds cpu time 0.04 seconds
NOTE: No observations in data set WORK.DAT. NOTE: The data set WORK.DAT1 has 0 observations and 3 variables. NOTE: PROCEDURE MEANS used: real time 0.34 seconds cpu time 0.06 seconds
22: LINE and COLUMN cannot be determined. NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where the error has occurred. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, INPUT, PUT. WARNING: Apparent symbolic reference SMPLSIZE not resolved.
NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DAT2 may be incomplete. When this step was stopped there were 0 observations and 2 variables. NOTE: DATA statement used: real time 0.01 seconds cpu time 0.01 seconds
NOTE: Line generated by the invoked macro "LIMIT". 26 data dat; do i=1 to &smplsize; x=ranuni(0); x=-0.59+(x**0.0355-(1-x)**0.1179)/0.1206; - 22 26 ! output; end;run; proc means data=dat; var x; output out=dat1 mean=meanx;run; data dat2; 26 ! set dat1; smplsize=&smplsize; keep smplsize meanx; WARNING: Apparent symbolic reference SMPLSIZE not resolved