<?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 to use a macro variable in index function? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-macro-variable-in-index-function/m-p/135910#M27569</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I am trying to search for some strings in a text, and I want to use the strings with macro variable so I be able to change the string. However, I am not sure how to use the macro variable in the index function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example,I am doing such thing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let str=William;&lt;/P&gt;&lt;P&gt;y=index(line,&amp;amp;str);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this the correct form since there are no ' ' around the variable &amp;amp;str? I am asking this because I see the SAS does not find the specified string in the text, although I know it is there. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will be grateful if someone helps me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Jul 2014 18:02:26 GMT</pubDate>
    <dc:creator>Shayan2012</dc:creator>
    <dc:date>2014-07-24T18:02:26Z</dc:date>
    <item>
      <title>How to use a macro variable in index function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-macro-variable-in-index-function/m-p/135910#M27569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I am trying to search for some strings in a text, and I want to use the strings with macro variable so I be able to change the string. However, I am not sure how to use the macro variable in the index function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example,I am doing such thing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let str=William;&lt;/P&gt;&lt;P&gt;y=index(line,&amp;amp;str);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this the correct form since there are no ' ' around the variable &amp;amp;str? I am asking this because I see the SAS does not find the specified string in the text, although I know it is there. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will be grateful if someone helps me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 18:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-macro-variable-in-index-function/m-p/135910#M27569</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-07-24T18:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a macro variable in index function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-macro-variable-in-index-function/m-p/135911#M27570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%let str=William;&lt;/P&gt;&lt;P&gt;y=index(line,&lt;STRONG&gt;"&amp;amp;str"&lt;/STRONG&gt;);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 18:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-macro-variable-in-index-function/m-p/135911#M27570</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-24T18:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a macro variable in index function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-macro-variable-in-index-function/m-p/135912#M27571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you are working with text-string in an SAS-macro environment look at the sas-macrofunctions (they all start with a %) &lt;/P&gt;&lt;P&gt;When you are using SAS-macro variables in a sas-datastep&amp;nbsp; and process those in a string make sure there quotes.&amp;nbsp;&amp;nbsp; '&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro-variable itself can contain&amp;nbsp; quotes&lt;/P&gt;&lt;P&gt; %let str='William';&lt;/P&gt;&lt;P&gt;y=index(line,&amp;amp;str);&lt;/P&gt;&lt;P&gt;or use the double quotes to indicate the &amp;amp; are sasmacro-variables to be resolved. (Single quotes will cause no resolving of macros)&lt;/P&gt;&lt;P&gt; %let str=William;&lt;/P&gt;&lt;P&gt;y=index(line,"&amp;amp;str");&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 18:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-macro-variable-in-index-function/m-p/135912#M27571</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-07-24T18:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a macro variable in index function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-macro-variable-in-index-function/m-p/135913#M27572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot guys!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 21:05:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-macro-variable-in-index-function/m-p/135913#M27572</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-07-24T21:05:21Z</dc:date>
    </item>
  </channel>
</rss>

