@Jcorti wrote:
Why this does not work??
data test (keep=jj);;
do ii=1 to 100;
do jj=1 to 25 ;
i = %sysfunc(putn(jj,z2.));
output;
end;
end;
run;
ERROR: Argument 1 to function PUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.
ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC
or %QSYSFUNC function reference is terminated.
43 i = %sysfunc(putn(jj,z2.));
_
22
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.
%sysfunc is a macro function that is resolved by the macro processor before the data step is compiled, so it never has access to data step variable values, only names. The way it's written here, it then tries to run the data step function as
putn("jj",z2.)
Since putn expects a numeric value as its first argument -> boom.
The %sysfunc wrapper was a remnant from your earlier code and should have been removed.
... View more