BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
How to print the macro value after it is resolved to output window. Usually we see it in the log window.
4 REPLIES 4
deleted_user
Not applicable
would this be satisfactory?[pre] data _null_ ;
* to print the value of macro variable named in &var;
file print ;
put "&var=" "&&&var" ;
stop ;
run;[/pre]Or, to print the values of all, with their current scope[pre] proc sort data= sashelp.vmacro out= _data_ ;
by scope name offset ;
run ;
proc print ;
by scope ;
id name ;
var offset value ;
run;[/pre]

try it to see.

PeterC
SASPhile
Quartz | Level 8
It works!
%macro test;
data _null_ ;
* to print the value of macro variable named in &var;
file print ;
put "&var=" "&&&var" ;
stop ;
run;
%mend test;
%test;
deleted_user
Not applicable
Rather than examine macro variable values in the output window, I just press a function key programmed to show my version of SASHELP.VMACRO in a viewtable window (or whenever the client's licence permits, in an FSview window because customising that is simpler) . The command is just [pre] vt sashelp.vmacro colheading=name[/pre]
I prefer the list to be ordered, so keep a view in my sasuser folder that is similar to the SASHELP.VMACRO view[pre] proc sql ;
create view sasuser.vmacro as
select scope as s format=$2.
, name format=$15.
, offset/200 as off format= 3.
, value format= $40.
, scope
, offset
from sashelp.vmacro
order by scope descending, name, offset
;
quit ;[/pre] The differences I introduced are as follows:
To most quickly locate any macro variable, I prefer the view to list names in order. Sorting first by "scope descending" places my macro variables before those which are automatic. If I should use this view within a macro, SCOPE names the macro in which each macro var was created. As sashelp.VMACRO predates SAS7 the 200 width limit is respected and a wide value is broken in 200 byte chunks and OFFSET is the real offset. Providing a narrower space for that value in my window, my view divides offfset by 200.

Then rather than submit code to review macro variable values, I just press a function key that issues command [pre] vt sasuser.vmacro colheading=name[/pre] or [pre] fsview sasuser.vmacro ; formula [/pre] ("formula" command in an FSView window retrieves customisation I prepared earlier, controlling window contents - column sizes, colors and order, and window size & position.
Some users like a mouse alternative to function keys, and prepare the command behind a new icon they create in the toolbar. Then they can easily view the current state of all macro variables at the touch of a button.
I guess (hope) there is something similar with E.G.

PeterC
kiranp
Calcite | Level 5

BIG THANKS to all ideas!
I solved it by including my statements into a dataset, but I can't understand why my initial version works for only a few people.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 18412 views
  • 2 likes
  • 3 in conversation