BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SasStatistics
Pyrite | Level 9
Trying to run this code I don't get anything?

The purpose is to use one argument with multiple table names and then extract the column names from each table.

Tom
Super User Tom
Super User

I updated the code to use FINDW() to make it easier, try it now.  

 

The concept is the same, pass the list of values in one parameter and write your macro to use the list. You can work out the details or what method works best for your situation.

 

For example you might just want to use the space delimited value in the generated code:

%mymacro(varlist);
proc print data=sashelp.class;
  var &varlist;
run;
%mend;
%mymacro(name age sex)

or use a %DO loop;

%mymacro(dslist);
%local i dsn ;
%do i=1 %to %sysfunc(countw(&dslist,%str( )));
  %let dsn=%scan(&dslist,%str( ));
proc print data=&dsn;
run;
%mend;
%mymacro(sashelp.class sashelp.cars(obs=10))

Or use some other delimiter besides space, like | or ^ that cannot appear in the actual values being passed.  I would avoid using comma as that will mean you need to use macro quoting to avoid SAS thinking you mean values for multiple parameters.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 16 replies
  • 3642 views
  • 6 likes
  • 4 in conversation