<?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 How to remove data based on datetime22.3 date value from a library of datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-data-based-on-datetime22-3-date-value-from-a/m-p/606068#M175946</link>
    <description>&lt;P&gt;I have a set of 100 datasets and need to remove data which was entered after 01jan2019 in all datasets which has a common variable called "masterdate". the date variable is in datetime22.3 format and with numeric type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help in how to do it&lt;/P&gt;</description>
    <pubDate>Thu, 21 Nov 2019 10:17:12 GMT</pubDate>
    <dc:creator>noda6003</dc:creator>
    <dc:date>2019-11-21T10:17:12Z</dc:date>
    <item>
      <title>How to remove data based on datetime22.3 date value from a library of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-data-based-on-datetime22-3-date-value-from-a/m-p/606068#M175946</link>
      <description>&lt;P&gt;I have a set of 100 datasets and need to remove data which was entered after 01jan2019 in all datasets which has a common variable called "masterdate". the date variable is in datetime22.3 format and with numeric type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help in how to do it&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 10:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-data-based-on-datetime22-3-date-value-from-a/m-p/606068#M175946</guid>
      <dc:creator>noda6003</dc:creator>
      <dc:date>2019-11-21T10:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove data based on datetime22.3 date value from a library of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-data-based-on-datetime22-3-date-value-from-a/m-p/606074#M175950</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240711"&gt;@noda6003&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro del_obs (libin, libout);

	proc contents data=&amp;amp;libin.._all_ noprint out=dataset_list;
	run;

	proc sort data=dataset_list (keep=memname) nodupkey;
		by memname;
	run;

	data _null_;
		set dataset_list;
		call symputx('dataset'||left(_n_), memname);
		call symputx('nb_dataset',_n_);
	run;

	proc datasets lib=work;
		delete dataset_list;
	run;
	
	%do i=1 %to &amp;amp;nb_dataset;
	
		data &amp;amp;libout..&amp;amp;&amp;amp;dataset&amp;amp;i;
			set &amp;amp;libin..&amp;amp;&amp;amp;dataset&amp;amp;i;
			where masterdate &amp;lt; "01JAN2019"d;
		run;
		
	%end;	

%mend del_obs;

%del_obs(library1, library2); /* Specify the libname for entry datasets, and then for output datasets*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 11:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-data-based-on-datetime22-3-date-value-from-a/m-p/606074#M175950</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-11-21T11:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove data based on datetime22.3 date value from a library of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-data-based-on-datetime22-3-date-value-from-a/m-p/606075#M175951</link>
      <description>&lt;P&gt;Pleas try the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) create a libname with name folder which has all the datasets&lt;/P&gt;
&lt;P&gt;2) create a dataset by name list which had all dataset names&lt;/P&gt;
&lt;P&gt;3) use this list with datasets names with call execute we run the prod sort step for every dataset with the subset condition where we will keep only the records with masterdate on or before 01Jan2019.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname folder '~path';

proc sql;
create table list as select memname from dictionary.tables where libname='FOLDER';
quit;

data _null_;
set list;
call execute('proc sort data=folder.'||strip(memname)||' out='||strip(memname)||';by var1;where datepart(masterdate)&amp;lt;="01jan2019"d;run;');
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 10:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-data-based-on-datetime22-3-date-value-from-a/m-p/606075#M175951</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-11-21T10:49:27Z</dc:date>
    </item>
  </channel>
</rss>

