BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Emjay
Obsidian | Level 7

I'm defining a variable number of macro variables that I want to use later in my program.

The number of those user-defined macro variables will also be a parameter later.

 

So let's say:

%let Opt1= 'abcd' 'efgd';
%let Opt2= 'abascd' 'efgretd';
%let Opt3= 'abgfcd' 'eqqwfgd';
%let Count_Opt=3; /* I don't want to do this manually. */

Is there a way to write those variables in a list and count this number then?

 

The only thing I found was the

%put _user_;

statement to see all my defined variables but this writes to the log only. And even if I could manage to acces this list, I need to somehow just get that variables that start with "Opt".

 

Is there a way or do I have to stick to manually defining this number?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

THe list is in the Dictionary table, which you can access and count.

 

SASHELP.VMACRO is the name of the table.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

THe list is in the Dictionary table, which you can access and count.

 

SASHELP.VMACRO is the name of the table.

--
Paige Miller
Emjay
Obsidian | Level 7

Wow, thanks for the quick help!

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
  • 2 replies
  • 1304 views
  • 3 likes
  • 2 in conversation