strange response of countw

Accepted Solution Solved
Reply
Senior User
Posts: 1
Accepted Solution

strange response of countw

[ Edited ]

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"

Accepted Solutions
Solution
‎11-18-2017 11:21 AM
Valued Guide
Posts: 531

Re: strange response of countw

Posted in reply to romangelzhaeuse

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


All Replies
Solution
‎11-18-2017 11:21 AM
Valued Guide
Posts: 531

Re: strange response of countw

Posted in reply to romangelzhaeuse

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

SAS Super FREQ
Posts: 497

Re: strange response of countw

Posted in reply to romangelzhaeuse

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
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 198 views
  • 2 likes
  • 3 in conversation