<?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: Include dataset in SET statement only if it exists? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391736#M66244</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.group_1;
a = 123;
run;

proc sql noprint ;
%let memlist=_null_;
  select catx('.',libname,memname)
    into :memlist separated by ' '
    from dictionary.members 
    where libname='WORK'
      and ((memname like 'group^_%' escape '^'))
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this but I'm getting this.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;NOTE: No rows were selected.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Wed, 30 Aug 2017 05:40:55 GMT</pubDate>
    <dc:creator>Ltwo</dc:creator>
    <dc:date>2017-08-30T05:40:55Z</dc:date>
    <item>
      <title>Include dataset in SET statement only if it exists?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391725#M66242</link>
      <description>&lt;P&gt;Hi, I'm looking to code up a data step at the end of my program that concatenates all existing datasets. I currently have to do it manually by checking which datasets exist. See example below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data final;
set
group_1-group_10
team_1-team_10;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sometimes one or more of the datasets might not exist (and that's fine) but is there a quicker way to code this so I do not have to manually check which datasets exists and commenting out before running the data step?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 04:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391725#M66242</guid>
      <dc:creator>Ltwo</dc:creator>
      <dc:date>2017-08-30T04:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Include dataset in SET statement only if it exists?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391732#M66243</link>
      <description>&lt;P&gt;You could just query the metadata to see what membernames match your patterns. &amp;nbsp;For example this query will just look for any members that start with GROUP_ or TEAM_ but you could make it more complicated if you required that the part after the underscore was an integer. Or even an integer between 1 and 10.&lt;/P&gt;
&lt;P&gt;Note that if you preset the macro variable to _NULL_ before the SQL query then when the data step runs it will generate and empty (zero obs and zero vars) dataset when no members match your pattern.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
%let memlist=_null_;
  select catx('.',libname,memname)
    into :memlist separated by ' '
    from dictionary.members 
    where libname='WORK'
      and ((memname like 'GROUP^_%' escape '^')
        or (memname like 'TEAM^_%' escape '^'))
  ;
quit;

data want ;
  set &amp;amp;memlist;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Aug 2017 05:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391732#M66243</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-30T05:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Include dataset in SET statement only if it exists?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391736#M66244</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.group_1;
a = 123;
run;

proc sql noprint ;
%let memlist=_null_;
  select catx('.',libname,memname)
    into :memlist separated by ' '
    from dictionary.members 
    where libname='WORK'
      and ((memname like 'group^_%' escape '^'))
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this but I'm getting this.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;NOTE: No rows were selected.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 30 Aug 2017 05:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391736#M66244</guid>
      <dc:creator>Ltwo</dc:creator>
      <dc:date>2017-08-30T05:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Include dataset in SET statement only if it exists?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391739#M66245</link>
      <description>&lt;P&gt;When selecting for library or dataset names, always use uppercase:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.group_1;
a = 123;
run;

proc sql noprint ;
%let memlist=_null_;
  select catx('.',libname,memname)
    into :memlist separated by ' '
    from dictionary.members 
    where libname='WORK'
      and ((memname like 'GROUP^_%' escape '^'))
  ;
quit;

%put &amp;amp;memlist;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Aug 2017 06:07:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391739#M66245</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-08-30T06:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Include dataset in SET statement only if it exists?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391741#M66246</link>
      <description>Thanks, changed to uppercase and it worked.</description>
      <pubDate>Wed, 30 Aug 2017 06:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Include-dataset-in-SET-statement-only-if-it-exists/m-p/391741#M66246</guid>
      <dc:creator>Ltwo</dc:creator>
      <dc:date>2017-08-30T06:21:36Z</dc:date>
    </item>
  </channel>
</rss>

