<?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: drop all variables with same suffix--letters only in name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/drop-all-variables-with-same-suffix-letters-only-in-name/m-p/870767#M343953</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'%OBS' was exactly what I needed. I thought I had tried that but apparently not.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2023 13:21:51 GMT</pubDate>
    <dc:creator>SarahBOtto</dc:creator>
    <dc:date>2023-04-20T13:21:51Z</dc:date>
    <item>
      <title>drop all variables with same suffix--letters only in name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/drop-all-variables-with-same-suffix-letters-only-in-name/m-p/870661#M343890</link>
      <description>&lt;P&gt;Hi. I am trying to drop all variables in a data set when the name ends with 'obs' (eg. ASQ2CM_A5obs&amp;nbsp; or ASQ60GM_C2obs) . Below is the code I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc contents data=out3 out=contents(keep=name) noprint ; run;&lt;BR /&gt;proc sql noprint ;&lt;BR /&gt;select name into :droplist separated by ' '&lt;BR /&gt;from contents&lt;BR /&gt;where upcase(name) like '%^OBS' escape '^'&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;data out4 ;&lt;BR /&gt;set out3 (drop=&amp;amp;droplist);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, I get the following error message&lt;/P&gt;&lt;P&gt;ERROR: Like pattern is not a valid pattern due to the invalid use of the escape pattern.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know a similar question has been asked already but I am having trouble figuring out the escape pattern issue. Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 22:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/drop-all-variables-with-same-suffix-letters-only-in-name/m-p/870661#M343890</guid>
      <dc:creator>SarahBOtto</dc:creator>
      <dc:date>2023-04-19T22:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: drop all variables with same suffix--letters only in name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/drop-all-variables-with-same-suffix-letters-only-in-name/m-p/870669#M343895</link>
      <description>&lt;P&gt;Why do you have the ^ in your like string?&lt;/P&gt;
&lt;P&gt;The only thing you can escape are the wildcards % and _ and the escape character itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you either need&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;upcase(name) like '%^_OBS' escape '^'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to match names that end in _OBS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if you are using VALIDVARNAME=ANY then perhaps&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;upcase(name) like '%^^OBS' escape '^'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to match names that end in ^OBS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to match a pattern of underscore then 0 or more characters and then OBS then use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;upcase(name) like '%^_%OBS' escape '^'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you only want it match when there are exactly 5 characters after the _ then use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;upcase(name) like '%^___OBS' escape '^'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 22:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/drop-all-variables-with-same-suffix-letters-only-in-name/m-p/870669#M343895</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-19T22:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: drop all variables with same suffix--letters only in name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/drop-all-variables-with-same-suffix-letters-only-in-name/m-p/870767#M343953</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'%OBS' was exactly what I needed. I thought I had tried that but apparently not.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 13:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/drop-all-variables-with-same-suffix-letters-only-in-name/m-p/870767#M343953</guid>
      <dc:creator>SarahBOtto</dc:creator>
      <dc:date>2023-04-20T13:21:51Z</dc:date>
    </item>
  </channel>
</rss>

