BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

%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?

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 851 views
  • 0 likes
  • 4 in conversation