<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using COUNTW function on macro variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203604#M266980</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is weird. I got ERROR info running your code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let test =;&lt;/P&gt;&lt;P&gt;%put test has a word count of %sysfunc(countw(%bquote(&amp;amp;test)));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;test has a word count of 0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 25 Apr 2015 08:11:56 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-04-25T08:11:56Z</dc:date>
    <item>
      <title>Using COUNTW function on macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203599#M266975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm hoping for some help in understanding the results I'm getting in the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let test =;&lt;/P&gt;&lt;P&gt;%put test has a word count of %sysfunc(countw(test));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the case of an empty macro variable, countw returns a value of 1. I'd like the result to be 0 in this case, which seems like it should be the result, but I'm clearly missing something in the documentation. Is there a way to have this return 0 by using some combination of optional arguments? If so, what would that be?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 19:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203599#M266975</guid>
      <dc:creator>emikea</dc:creator>
      <dc:date>2015-04-24T19:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using COUNTW function on macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203600#M266976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you might want to use&lt;/P&gt;&lt;P&gt;%put test has a word count of %sysfunc(countw(&amp;amp;test));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And furthermore, you might want to perform a test of &amp;amp;test to make sure it isn't an empty string, which it is in your example. If its an empty string, you can return a value of 0 and branch around the actual use of countw&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 20:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203600#M266976</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-04-24T20:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using COUNTW function on macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203601#M266977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My apologies. Leaving out the ampersand was a typo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm actually trying to have countw return 0 when the string is empty. It seems like that should be the result.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 20:23:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203601#M266977</guid>
      <dc:creator>emikea</dc:creator>
      <dc:date>2015-04-24T20:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using COUNTW function on macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203602#M266978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is problem with the way that %SYSFUNC() parses and passes the arguments to the function.&lt;/P&gt;&lt;P&gt;You could either test first or just append a space (or whatever you delimiter is) to the end of the argument.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; background-color: #ffffff;"&gt;%put %sysfunc(countw(&amp;amp;test%str( )));&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 21:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203602#M266978</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-04-24T21:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using COUNTW function on macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203603#M266979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Tom.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 23:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203603#M266979</guid>
      <dc:creator>emikea</dc:creator>
      <dc:date>2015-04-24T23:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using COUNTW function on macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203604#M266980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is weird. I got ERROR info running your code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let test =;&lt;/P&gt;&lt;P&gt;%put test has a word count of %sysfunc(countw(%bquote(&amp;amp;test)));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;test has a word count of 0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Apr 2015 08:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-COUNTW-function-on-macro-variables/m-p/203604#M266980</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-04-25T08:11:56Z</dc:date>
    </item>
  </channel>
</rss>

