<?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: counting variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/counting-variables/m-p/79966#M17224</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This approach can be done, but involves several complications.&amp;nbsp; To use CATX in macro language, you need to place it inside %SYSFUNC.&amp;nbsp; To refer to a blank in macro language, you have to refer to %str( ) rather than ' '.&amp;nbsp; And what does &amp;amp;VAR_NAME actually refer to?&amp;nbsp; Don't you have 10 macro variables rather than a single &amp;amp;VAR_NAME?&amp;nbsp; Otherwise what are you concatenating?&amp;nbsp; Or does &amp;amp;VAR_NAME already contain a series of commas embedded within it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the off-chance that the answer is that you have a set of macro variables &amp;amp;VAR_NAME1, &amp;amp;VAR_NAME2, etc., here is an easier way to concatenate them:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%local i var_count;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;_N_Var_values_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let var_count = &amp;amp;var_count &amp;amp;&amp;amp;var_name&amp;amp;i;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure I have the right picture here.&amp;nbsp; Why would you want to use the name &amp;amp;VAR_COUNT to hold the final string of concatenated variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe you can clarify what you are trying to accomplish.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jul 2013 01:29:46 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2013-07-16T01:29:46Z</dc:date>
    <item>
      <title>counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-variables/m-p/79965#M17223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is an extract from a macro program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;_N_Var_values_&amp;gt;1 and &amp;amp;_N_Var_values_&amp;lt;=10 %then&lt;/P&gt;&lt;P&gt;%let var_count=catx(' ',&amp;amp;var_name);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to concatenate variable names having number of levels from 1 to 10 in&amp;nbsp; a macro variable &lt;STRONG&gt;var_count&lt;/STRONG&gt; but not getting the desired results. Please advise how can I modify &lt;/P&gt;&lt;P&gt;%let var_count=catx(' ',&amp;amp;var_name) so that I can have variables in the following format&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a b d g (Qualifying constraint from 1 to 10).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 00:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-variables/m-p/79965#M17223</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2013-07-16T00:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-variables/m-p/79966#M17224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This approach can be done, but involves several complications.&amp;nbsp; To use CATX in macro language, you need to place it inside %SYSFUNC.&amp;nbsp; To refer to a blank in macro language, you have to refer to %str( ) rather than ' '.&amp;nbsp; And what does &amp;amp;VAR_NAME actually refer to?&amp;nbsp; Don't you have 10 macro variables rather than a single &amp;amp;VAR_NAME?&amp;nbsp; Otherwise what are you concatenating?&amp;nbsp; Or does &amp;amp;VAR_NAME already contain a series of commas embedded within it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the off-chance that the answer is that you have a set of macro variables &amp;amp;VAR_NAME1, &amp;amp;VAR_NAME2, etc., here is an easier way to concatenate them:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%local i var_count;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;_N_Var_values_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let var_count = &amp;amp;var_count &amp;amp;&amp;amp;var_name&amp;amp;i;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure I have the right picture here.&amp;nbsp; Why would you want to use the name &amp;amp;VAR_COUNT to hold the final string of concatenated variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe you can clarify what you are trying to accomplish.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 01:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-variables/m-p/79966#M17224</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-07-16T01:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-variables/m-p/79967#M17225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Astounding - I've a lot of variables in dataset and I am trying to create a macro variable by selecting&amp;nbsp; variables containing maximum 10 different values for classification analyses. Code mentioned above is helpful in identifying required variables. If I need to access var_count variable outside the macro what changes should I make in the syntax? Secondly on first iteration what value is being assigned to&amp;nbsp; &amp;amp;var_count?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let var_count = &amp;amp;var_count &amp;amp;&amp;amp;var_name&amp;amp;i;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 13:27:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-variables/m-p/79967#M17225</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2013-07-16T13:27:33Z</dc:date>
    </item>
  </channel>
</rss>

