<?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 Can we filter datasets from library based on date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600308#M173480</link>
    <description>&lt;P&gt;I have library of datasets with one common date variable and want to extract datasets with where date lt '27SEP2018'.&lt;/P&gt;
&lt;P&gt;Can i do it for all datasets at one step?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Oct 2019 09:52:22 GMT</pubDate>
    <dc:creator>vraj1</dc:creator>
    <dc:date>2019-10-30T09:52:22Z</dc:date>
    <item>
      <title>Can we filter datasets from library based on date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600308#M173480</link>
      <description>&lt;P&gt;I have library of datasets with one common date variable and want to extract datasets with where date lt '27SEP2018'.&lt;/P&gt;
&lt;P&gt;Can i do it for all datasets at one step?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 09:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600308#M173480</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2019-10-30T09:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can we filter datasets from library based on date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600311#M173482</link>
      <description>&lt;P&gt;You want to extract all the data sets that has the value&amp;nbsp;&lt;SPAN&gt;27SEP2018 in just one or more value(s) in a specific variable, that is named the same in all the dataset, correct?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What do you want to do with those data sets then?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 09:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600311#M173482</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-30T09:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can we filter datasets from library based on date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600313#M173484</link>
      <description>&lt;P&gt;extract all datasets with data which has date less than '12SEP2018'. So if a dataset has date variable which has different dates and i want to extract only observations which has date less than&amp;nbsp;'12SEP2018'. and want to do for all datasets in a folder&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 09:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600313#M173484</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2019-10-30T09:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can we filter datasets from library based on date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600314#M173485</link>
      <description>&lt;P&gt;Please try the below code, please replace the sashelp in the beow code with your libname and it should work. Considering that the date variable name is date and is in character format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table want as select memname from dictionary.tables where lowcase(libname)='sashelp';
quit;

data _null_;
set want;
call execute('data '||memname||';set sashelp.'||strip(memname)||'; where date ="27SEP2018";run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 10:04:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600314#M173485</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-10-30T10:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can we filter datasets from library based on date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600322#M173493</link>
      <description>&lt;P&gt;Something like this may work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fdsa;
  date='01jan2018'd;
  format date date9.;
  do x=1 to 5;
    output;
	end;
run;

data fdsasf;
  date='01jan2020'd;
  format date date9.;
  do x=1 to 5;
    output;
	end;
run;

data test;
  set work.f:(where=(date&amp;lt;='01sep2018'd) obs=1) indsname=dsn;
  old_dsname=dsn;
  keep old_dsname;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;using this construct means that all your table names must have at least the first letter in common, SAS will not accept a general wildcard like "WORK.:".&amp;nbsp; If that is not the case, or if your tables are mixed with other tables that do not have a DATE variable, you can use SQL to generate the list of tables to read instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select cats(libname,'.',memname,"(where=(date&amp;gt;'01sep2018'd) obs=1)") into :inds separated by ' '
    from dictionary.columns where libname='WORK' and upcase(name)='DATE';
quit;&lt;BR /&gt;
data test;
  set &amp;amp;inds indsname=dsn;
  old_dsname=dsn;
  keep old_dsname;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2019 10:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-we-filter-datasets-from-library-based-on-date/m-p/600322#M173493</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-10-30T10:42:44Z</dc:date>
    </item>
  </channel>
</rss>

