Egodym
Egodym

Reputation: 451

Writing into SAS log

I know I can use %PUT to write a text string in the log window, but what if I want to write in the log the result of a function, for example PROBNORM(x)? Is there a way to do that?

Upvotes: 3

Views: 576

Answers (2)

Joe
Joe

Reputation: 63424

In the data step, PUT and PUTLOG functions will write to the log using data step variables. You can't use a function directly, but if you assign the value to a variable you can write that variable.

data _null_;
 x=1;
 y = probnorm(x);
 put "Probnorm is " y=;
run;

While you can do so using %PUT and %SYSFUNC, they have a significant limitation in that they cannot access data step variables (without a lot of work anyway).

Upvotes: 4

DomPazz
DomPazz

Reputation: 12465

Use %sysfunc() to evaluate a function during macro resolution.

IE

%let x=1;
%put %sysfunc(probnorm(&x));

Upvotes: 5

Related Questions