08-26-2013 12:19 PM
I tend to stay away from macro variables, but sometimes you just have to....
I create "x" number of macro varaibles with this loop:
DO I=1 TO months by 1;
Is there something simple that I can use to list the contents of all the variables created? Usually
I just use a "%put varname", but that won't work in this case because I don't know how many
variables are created.
Thanks in advance.
08-26-2013 12:37 PM
I'm actually using %put _global_ which gives me a shorter list, but I was looking for something that
would only list the macro variables created by the loop.
08-26-2013 12:51 PM
To generalize you could save a copy of the dictionary table before the block of code you want to test and then pull the differences after the code block.
%symdel x1 ;
%symdel x2 ;
proc sql noprint ;
create table save as select * from dictionary.macros ;
proc sql ;
select * from dictionary.macros
except select * from save
08-26-2013 12:28 PM
proc sql; select * from dictionary.macros; quit; Will show all of the macro variables. Add an appropriate where to look for Name starting with "month" should get you there.
08-26-2013 09:14 PM
OK, now here's the exact way. Insert into your DO loop, just before the END:
call execute('%put month' || trim(left(put(i,3.))) || ' is &month' || trim(left(put(i,3.))) || ';');
08-27-2013 09:48 AM
do x=1 by 1 until(done);
set sashelp.class end=done;
call symputx( cats('name',x) , name );
call symputx( 'name0' , x );
%do x=1 %to &name0;