<?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 how can I automatically count the number of items in a macro variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-automatically-count-the-number-of-items-in-a-macro/m-p/439526#M109680</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to know how to automatically determine the number of items in &amp;amp; type(=26) instead of declaring&amp;nbsp;26 in the below script....&lt;BR /&gt;Just a very simple example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; type= A B C D E F G H I J K L M N O P R S T U V W X Y Z ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;_NULL_&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;26&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &amp;nbsp; &amp;lt;---- this value of&amp;nbsp;25 is what I would like to automate when I change &amp;amp;type.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Number=i&amp;nbsp;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Feb 2018 00:31:47 GMT</pubDate>
    <dc:creator>Jiawenabby8</dc:creator>
    <dc:date>2018-02-23T00:31:47Z</dc:date>
    <item>
      <title>how can I automatically count the number of items in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-automatically-count-the-number-of-items-in-a-macro/m-p/439526#M109680</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to know how to automatically determine the number of items in &amp;amp; type(=26) instead of declaring&amp;nbsp;26 in the below script....&lt;BR /&gt;Just a very simple example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; type= A B C D E F G H I J K L M N O P R S T U V W X Y Z ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;_NULL_&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;26&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &amp;nbsp; &amp;lt;---- this value of&amp;nbsp;25 is what I would like to automate when I change &amp;amp;type.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Number=i&amp;nbsp;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 00:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-automatically-count-the-number-of-items-in-a-macro/m-p/439526#M109680</guid>
      <dc:creator>Jiawenabby8</dc:creator>
      <dc:date>2018-02-23T00:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: how can I automatically count the number of items in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-automatically-count-the-number-of-items-in-a-macro/m-p/439527#M109681</link>
      <description>&lt;P&gt;Assuming they're always space separated then the countw function should do the trick like so&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let type= A B C D E F G H I J K L M N O P R S T U V W X Y Z;
data _NULL_;
do i = 1 to countw("&amp;amp;type");  
put Number=i ;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Feb 2018 00:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-automatically-count-the-number-of-items-in-a-macro/m-p/439527#M109681</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2018-02-23T00:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: how can I automatically count the number of items in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-automatically-count-the-number-of-items-in-a-macro/m-p/439547#M109696</link>
      <description>&lt;P&gt;This may be a useful example for you:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1qvxz5u3uru7yn1nk7q64ohvwak.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1qvxz5u3uru7yn1nk7q64ohvwak.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and some more are here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n02xowj8yuqfo4n0zzi98shu8qup.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n02xowj8yuqfo4n0zzi98shu8qup.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 01:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-automatically-count-the-number-of-items-in-a-macro/m-p/439547#M109696</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-23T01:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: how can I automatically count the number of items in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-automatically-count-the-number-of-items-in-a-macro/m-p/439733#M109754</link>
      <description>&lt;P&gt;Your links are super helpful. Thanks so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 15:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-automatically-count-the-number-of-items-in-a-macro/m-p/439733#M109754</guid>
      <dc:creator>Jiawenabby8</dc:creator>
      <dc:date>2018-02-23T15:34:50Z</dc:date>
    </item>
  </channel>
</rss>

