<?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 Resolving FIND in macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Resolving-FIND-in-macro/m-p/649266#M194618</link>
    <description>&lt;P&gt;I am trying to use a macro to parse some strings.&amp;nbsp; This simplified code is supposed to find the rightmost underscore.&amp;nbsp; However, the Index is resolved as zero:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro resolveindex;&lt;BR /&gt;%let thisvar = PriPrb_SUM;&lt;BR /&gt;%LET Index = %SYSFUNC(FIND("&amp;amp;ThisVar.","_",-33));&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I know that macro variables are always character, I tried this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%LET Index = %SYSFUNC(PUT(FIND("&amp;amp;ThisVar.","_",-33),2.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I get an error message that PUT function is unknown.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I get this to work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 May 2020 15:40:08 GMT</pubDate>
    <dc:creator>Davanden</dc:creator>
    <dc:date>2020-05-20T15:40:08Z</dc:date>
    <item>
      <title>Resolving FIND in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-FIND-in-macro/m-p/649266#M194618</link>
      <description>&lt;P&gt;I am trying to use a macro to parse some strings.&amp;nbsp; This simplified code is supposed to find the rightmost underscore.&amp;nbsp; However, the Index is resolved as zero:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro resolveindex;&lt;BR /&gt;%let thisvar = PriPrb_SUM;&lt;BR /&gt;%LET Index = %SYSFUNC(FIND("&amp;amp;ThisVar.","_",-33));&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I know that macro variables are always character, I tried this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%LET Index = %SYSFUNC(PUT(FIND("&amp;amp;ThisVar.","_",-33),2.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I get an error message that PUT function is unknown.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I get this to work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 15:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-FIND-in-macro/m-p/649266#M194618</guid>
      <dc:creator>Davanden</dc:creator>
      <dc:date>2020-05-20T15:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving FIND in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-FIND-in-macro/m-p/649270#M194620</link>
      <description>&lt;PRE&gt;%let thisvar = PriPrb_SUM;
%LET Index = %SYSFUNC(FIND(&amp;amp;ThisVar.,_,-33));

%put &amp;amp;index.;&lt;/PRE&gt;
&lt;P&gt;Quotes in macro calls to data step functions are usually not needed since the macro processor treats everything as character.&lt;/P&gt;
&lt;P&gt;The function to examine a macro variable is %put.&lt;/P&gt;
&lt;P&gt;If you want to use the data step Put functions with %sysfunc you need to use either PUTN or PUTC explicitly.&lt;/P&gt;
&lt;P&gt;Note: if your Thisvar might have commas then you have another issue as it would be interpreted as a delimiter in the function call and you would need to use on of the macro quoting functions to have the comma ignored in the Find function.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 15:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-FIND-in-macro/m-p/649270#M194620</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-20T15:59:00Z</dc:date>
    </item>
  </channel>
</rss>

