BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

%let a=10 ;

%let b=20 ;

%let c=30 ;

I am creating 3 macro variables a,b,c so with out executing above code how to do like how many macro 

variables are present in that code (don't use _user_, sashelp.vmacro)

 

answer is 3

3 REPLIES 3
andreas_lds
Jade | Level 19

@thanikondharish wrote:

%let a=10 ;

%let b=20 ;

%let c=30 ;

I am creating 3 macro variables a,b,c so with out executing above code how to do like how many macro 

variables are present in that code (don't use _user_, sashelp.vmacro)

 

answer is 3


you may want to rephrase your post, so that the question you have is clear.

ballardw
Super User

Why the artificial "can't use" restriction?

 

Do you know how to read a text file? The program is text. Read it into a data set. Then Parse the data for the string "%let" to count the number of times that string is found would find your example.

 

 

Astounding
PROC Star

You will need to set some boundaries on the problem.  How complex can the code get?  For example, consider:

%let start = 10;
%let finish = 15;
%do i=&start %to &finish;
   %let var&i = 0;
%end;

Do you want to count that this code has 8 %let statements (2 before the loop, 6 inside the loop)?  Do you want to count &i which may be created but not with a %let statement?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 567 views
  • 0 likes
  • 4 in conversation