13 users online | 13 Guests and 0 Registered

How can I get details of a macro variable name / value written to the LOG?

It can be beneficial to write into the LOG values of a macro variable name and the stored value, particularly for LOCAL macro variables created inside a macro programme definition.

There has always been a shorthand method for writing dataset name / value pairs in to the LOG using the variable_name= syntax:

data _null_ ;
  set sashelp.class (obs= 2) ;
  put name= ;
run ;

giving a LOG containing the following:


To write out individual name / value pairs in the macro procesor required additional syntax, but since SAS version 9.3, adding an = after the ampersand will acheive the desired effect:

%macro countwords(text) ;
  %let wordcount = %sysfunc(countw(&text)) ;
  %put text = &text ; *** Additional syntax form *** ;
  %put &=wordcount ;  *** Shorthand notation     *** ;
%mend countwords ;

%countwords(Pink Chameleon)

as can be seen in the LOG:

text = Pink Chameleon
Alan D Rudland
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category