<?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: regex match dataset but not infile in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/regex-match-dataset-but-not-infile/m-p/771374#M244775</link>
    <description>&lt;P&gt;You seem to be comparing apples to oranges here.&lt;/P&gt;
&lt;P&gt;Change your second data step to define LINE as being of length $100 so that it matches how SAS guessed you wanted the variable defined in the first data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your REGEX needs to account for the trailing spaces that will be present in a SAS variable.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Sep 2021 14:00:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-09-30T14:00:45Z</dc:date>
    <item>
      <title>regex match dataset but not infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/regex-match-dataset-but-not-infile/m-p/771372#M244774</link>
      <description>&lt;P&gt;Hallo.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a file '~/test.sas' which contains one line&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    %metalibm(inlibdw);             * Bankdata DW;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;when i run&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
infile "~/test.sas" truncover;
input line $char100.;
commentEnd=prxparse('/(\*\/|;$)/');
end_=prxmatch(commentEnd,line);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get end_=0.But if I input the line in a dataset&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;
line=' %metalibm(inlibdw); * Bankdata DW;';
commentEnd=prxparse('/(\*\/|;$)/');
end_=prxmatch(commentEnd,line);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get end_=50 wich is corret.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea of why this happens?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 13:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/regex-match-dataset-but-not-infile/m-p/771372#M244774</guid>
      <dc:creator>rudfaden3</dc:creator>
      <dc:date>2021-09-30T13:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: regex match dataset but not infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/regex-match-dataset-but-not-infile/m-p/771374#M244775</link>
      <description>&lt;P&gt;You seem to be comparing apples to oranges here.&lt;/P&gt;
&lt;P&gt;Change your second data step to define LINE as being of length $100 so that it matches how SAS guessed you wanted the variable defined in the first data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your REGEX needs to account for the trailing spaces that will be present in a SAS variable.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 14:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/regex-match-dataset-but-not-infile/m-p/771374#M244775</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-30T14:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: regex match dataset but not infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/regex-match-dataset-but-not-infile/m-p/771377#M244776</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;trim(line)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Sep 2021 14:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/regex-match-dataset-but-not-infile/m-p/771377#M244776</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2021-09-30T14:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: regex match dataset but not infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/regex-match-dataset-but-not-infile/m-p/771465#M244823</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;consider the trailing blanks in your line variable with length=100.&lt;/P&gt;
&lt;P&gt;You are expecting a semi-colon at end of line, but you have a semi-colon followed by blanks instead&lt;/P&gt;
&lt;P&gt;Consider adding&amp;nbsp;&lt;STRONG&gt;\s*&lt;/STRONG&gt; to your &lt;EM&gt;regex&lt;/EM&gt; or use &lt;STRONG&gt;strip(&lt;/STRONG&gt;line&lt;STRONG&gt;)&lt;/STRONG&gt; in &lt;EM&gt;prxmatch&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;
line=' %metalibm(inlibdw); * Bankdata DW;';
commentEnd=prxparse('/(\*\/|;$)/');
end_=prxmatch(commentEnd,strip(line));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Edit: or trim(line) like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;said&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 19:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/regex-match-dataset-but-not-infile/m-p/771465#M244823</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2021-09-30T19:06:36Z</dc:date>
    </item>
  </channel>
</rss>

