<?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: Finding a series if the &amp;quot;number&amp;quot; is in the middle of a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679552#M205203</link>
    <description>&lt;P&gt;You might try SQL SELECT INTO, with a Pearl Regular Expression to find the datasets you are interested in (or not, actually):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select memname into :ToBeDeleted separated by ' ' from dictionary.tables
  where libname='HMP' and prxmatch('/adc_\d+_./i',memname);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then use the generated macro variable in PROC DATASETS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets nolist lib=hmp;
delete &amp;amp;ToBeDeleted;
run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Aug 2020 16:38:20 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2020-08-26T16:38:20Z</dc:date>
    <item>
      <title>Finding a series if the "number" is in the middle of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679427#M205163</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have this task of deleting around 100 datasets. But the problem is the datasets are named this way: adc_1_a, adc_2_a,......,adc_45_d, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried doing this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;proc datasets nolist lib=hmp;
delete adc_1_: - adc_45_;
run;quit;&lt;/LI-CODE&gt;&lt;P&gt;but this throws up an error.&lt;BR /&gt;How do I achieve this? Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 12:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679427#M205163</guid>
      <dc:creator>sam_sas2</dc:creator>
      <dc:date>2020-08-26T12:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a series if the "number" is in the middle of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679455#M205175</link>
      <description>&lt;P&gt;You can use metadata table DICTIONARY.TABLES to construct a list of tables that match some naming convention detectable with a regular expression pattern.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;Some sample data sets with the same common prefix (adc_:) but not all are adc_#_&amp;lt;letter&amp;gt;&lt;/P&gt;
&lt;PRE&gt;* create some sample data sets whose names start with adc_;&lt;BR /&gt;data adc_1_a adc_2_a adc_45_d adc_patients;
x=1;
run;
&lt;BR /&gt;%let tables=;&lt;BR /&gt;
proc sql;
  reset noprint;
  select memname into :tables separated by ' '
  from dictionary.tables
  where libname = 'WORK'                          /* sample data sets are in the WORK library */
    and prxmatch ('/adc_\d+_[abcd]/i', memname)   /* pattern for tables named adc_&amp;lt;digits&amp;gt;_&amp;lt;single letter a, b, c, or d&amp;gt; */
  ;

proc datasets nolist lib=work;
  delete &amp;amp;tables;
quit;

%symdel tables;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Aug 2020 16:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679455#M205175</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-08-26T16:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a series if the "number" is in the middle of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679456#M205176</link>
      <description>&lt;P&gt;Not clear what you don't want to delete. Is deleting anything starting with adc_ acceptable? If yes, use adc_: in the delete statement. If not, please define the rules identifying a dataset that should be deleted.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 13:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679456#M205176</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-08-26T13:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a series if the "number" is in the middle of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679467#M205182</link>
      <description>What's the purpose of first 3 lines?</description>
      <pubDate>Wed, 26 Aug 2020 13:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679467#M205182</guid>
      <dc:creator>sam_sas2</dc:creator>
      <dc:date>2020-08-26T13:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a series if the "number" is in the middle of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679468#M205183</link>
      <description>No, so I want to delete all datasets that have a number in between. I have datasets like adc_ab which I shouldn't delete. Hope this gives more clarity.</description>
      <pubDate>Wed, 26 Aug 2020 13:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679468#M205183</guid>
      <dc:creator>sam_sas2</dc:creator>
      <dc:date>2020-08-26T13:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a series if the "number" is in the middle of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679477#M205184</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327668"&gt;@sam_sas2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;No, so I want to delete all datasets that have a number in between. I have datasets like adc_ab which I shouldn't delete. Hope this gives more clarity.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS has an ANYDIGIT() function.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 13:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679477#M205184</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-26T13:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a series if the "number" is in the middle of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679484#M205185</link>
      <description>&lt;P&gt;The first three lines creates some sample data sets for the example code to work with.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 14:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679484#M205185</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-08-26T14:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a series if the "number" is in the middle of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679552#M205203</link>
      <description>&lt;P&gt;You might try SQL SELECT INTO, with a Pearl Regular Expression to find the datasets you are interested in (or not, actually):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select memname into :ToBeDeleted separated by ' ' from dictionary.tables
  where libname='HMP' and prxmatch('/adc_\d+_./i',memname);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then use the generated macro variable in PROC DATASETS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets nolist lib=hmp;
delete &amp;amp;ToBeDeleted;
run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Aug 2020 16:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-series-if-the-quot-number-quot-is-in-the-middle-of-a/m-p/679552#M205203</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-08-26T16:38:20Z</dc:date>
    </item>
  </channel>
</rss>

