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

When I tried to write a loop over some arguments countw gave me the answer that "where Gruppe=1!where Gruppe=2" consists of four words when using "!" as delimiter. Shouldn't it be 2? 

 

I used countw as shown in the log below.

 

61 %macro test;

62
63 %let a=%sysfunc(countw(where Gruppe=1!where Gruppe=2),!);
64 %put "&a.";
65 %mend;
66
67 %test;
"4"
1 ACCEPTED SOLUTION

Accepted Solutions
jklaverstijn
Rhodochrosite | Level 12

Looking at parentheses the ! is interpreted as a parameter for %sysfunc and not of countw. You're better of with

 

%sysfunc(countw(&Beds.,!));

Hope this helps,

- Jan

View solution in original post

2 REPLIES 2
jklaverstijn
Rhodochrosite | Level 12

Looking at parentheses the ! is interpreted as a parameter for %sysfunc and not of countw. You're better of with

 

%sysfunc(countw(&Beds.,!));

Hope this helps,

- Jan

WarrenKuhfeld
Ammonite | Level 13

Your parentheses are in the wrong place.   This works.  I deleted other extra characters that you do not need.

%macro test;
%let a=%sysfunc(countw(where Gruppe=1!where Gruppe=2,!));
%put &a;
%mend;
%test

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