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

Hello, Need a quick help!!

 

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

Like

 

%let Alist1 = '00123','00124','00175'....; (400 variables)

%let Alist2 = '00163','00164','00165'....;(500 variables)

%let Alist3 = '00153','00154','00155'....;(300 variables)

 

I wanted to check the count of ALIST1 in my log using %PUT statement, not the actual values. Since I am not sure how many were there in some of the lists.

 

I tried like this,

%PUT = &Alist1 ;

 

%PUT = count( &Alist1) ;

 

I need something like this

Alist = 400??

 

Thanks for checking!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14
Hi,
Have you tried this with the double quotes:
%put %sysfunc(countw("&Alist1"));

View solution in original post

8 REPLIES 8
novinosrin
Tourmaline | Level 20
%put %sysfunc(countw(%BQUOTE(&Alist1),%str(,)));
ed_sas_member
Meteorite | Level 14

Hi @Kalai2008 

You can use the count() function and use it with the %sysfunc() function as you use macro language;

%put %sysfunc(countw("&Alist1"));
Kalai2008
Pyrite | Level 9

Thanks,

Log Error:

 

NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
22
23 GOPTIONS ACCESSIBLE;
24 %put %sysfunc (countw(&AList1));
ERROR: The function COUNTW referenced by the %SYSFUNC or %QSYSFUNC macro function has too many arguments.
.

Kalai2008
Pyrite | Level 9
Thank you, but there is no values in log.

Log:
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
22
23 GOPTIONS ACCESSIBLE;
24 %put %sysfunc(countw(%BQUOTE(AList1),%str(,)));
1
25
ed_sas_member
Meteorite | Level 14
Hi,
Have you tried this with the double quotes:
%put %sysfunc(countw("&Alist1"));
Kalai2008
Pyrite | Level 9
Oh thanks, since I saw warning message, i didn't notice the output.
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
22
23 GOPTIONS ACCESSIBLE;
WARNING: The quoted string currently being processed has become more than 262 characters long. You might have unbalanced quotation
marks.
24 %put %sysfunc (countw("&AList1"));
235
25
ed_sas_member
Meteorite | Level 14
Just a question: is it normal to have a missing quotation mark before 00124 in you macro variable definition ?
%let Alist1 = '00123',00124','00175'....; (400 variables)
Kalai2008
Pyrite | Level 9
I don't have any missing quotation mark in any of the listed variable, I separated each with commas, not sure why i got that warning message,

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
  • 8 replies
  • 1918 views
  • 5 likes
  • 3 in conversation