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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 4079 views
  • 6 likes
  • 4 in conversation