<?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: Getting N-th (position) of a macro variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573436#M12499</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let variablenames = AAA BBB CCC DDD EEE FFF GGG;

data _null_;
   result=findw("&amp;amp;variablenames.","CCC"," ","E");
   put result=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 15 Jul 2019 05:18:36 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-07-15T05:18:36Z</dc:date>
    <item>
      <title>Getting N-th (position) of a macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573429#M12496</link>
      <description>&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling to find the answer to something that may be a simple thing. Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a macro variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let variablenames = AAA BBB CCC DDD EEE FFF GGG;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I want to find what position of&amp;nbsp; CCC which will show as 3. How can I achieve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 05:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573429#M12496</guid>
      <dc:creator>tonoplast</dc:creator>
      <dc:date>2019-07-15T05:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Getting N-th (position) of a macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573436#M12499</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let variablenames = AAA BBB CCC DDD EEE FFF GGG;

data _null_;
   result=findw("&amp;amp;variablenames.","CCC"," ","E");
   put result=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jul 2019 05:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573436#M12499</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-15T05:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting N-th (position) of a macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573440#M12502</link>
      <description>&lt;P&gt;Thank you very much! This was what I was looking for!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't specify but I wanted to put it in a separate macro variable, so I added some lines to your code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let variablenames = AAA BBB CCC DDD EEE FFF GGG;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;result=findw("&amp;amp;variablenames.","CCC"," ","E");&lt;BR /&gt;put result=; call symput("thisnum",result);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%put thisnum = &amp;amp;thisnum;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 05:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573440#M12502</guid>
      <dc:creator>tonoplast</dc:creator>
      <dc:date>2019-07-15T05:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Getting N-th (position) of a macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573441#M12503</link>
      <description>&lt;P&gt;Ah ok &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Anyway, glad you found your answer&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 05:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573441#M12503</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-15T05:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Getting N-th (position) of a macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573617#M12546</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264091"&gt;@tonoplast&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much! This was what I was looking for!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't specify but I wanted to put it in a separate macro variable, so I added some lines to your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let variablenames = AAA BBB CCC DDD EEE FFF GGG;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;result=findw("&amp;amp;variablenames.","CCC"," ","E");&lt;BR /&gt;put result=; call symput("thisnum",result);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put thisnum = &amp;amp;thisnum;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;T&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can use the macro function %sysfunc to call data step functions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let thisnum = %sysfunc(findw(&amp;amp;variablenames.,CCC,%str(' ') ,E));

%put &amp;amp;thisnum.;
&lt;/PRE&gt;
&lt;P&gt;Note that the quotes are needed in the macro language except when a specific blank is needed for some functions.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 17:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/573617#M12546</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-15T17:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting N-th (position) of a macro variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/574046#M12637</link>
      <description>&lt;P&gt;Thank you! This is great!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 00:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Getting-N-th-position-of-a-macro-variable/m-p/574046#M12637</guid>
      <dc:creator>tonoplast</dc:creator>
      <dc:date>2019-07-17T00:31:35Z</dc:date>
    </item>
  </channel>
</rss>

