filename myfile 'D:\Dropbox\Step1Log.log';
proc printto log=myfile;run;

libname database "D:\Dropbox\EPA Data\Code and Data\Data\Database";
libname data "F:\SAS data files";*Edgar log data saved in MyBook;
*******************************************************************************;
*******************************************************************************;
*******************************************************************************;
*0. Extract EPA downloads from Edgar log;
*Year 2003;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2003 data=x1 force; run;
  %end;
%mend;    
%epa(20030102,20031231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2003 data=x1 force; run;
  %end;
%mend;    
%epa(20030102,20031231);
*Year 2004;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2004 data=x1 force; run;
  %end;
%mend;    
%epa(20040101,20041231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2004 data=x1 force; run;
  %end;
%mend;    
%epa(20040101,20041231);
*Year 2005;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2005 data=x1 force; run;
  %end;
%mend;    
%epa(20050101,20051231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2005 data=x1 force; run;
  %end;
%mend;    
%epa(20050101,20051231);
*Year 2006;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2006 data=x1 force; run;
  %end;
%mend;    
%epa(20060101,20061231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2006 data=x1 force; run;
  %end;
%mend;    
%epa(20060101,20061231);
*Year 2007;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2007 data=x1 force; run;
  %end;
%mend;    
%epa(20070101,20071231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2007 data=x1 force; run;
  %end;
%mend;    
%epa(20070101,20071231);
*Year 2008;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2008 data=x1 force; run;
  %end;
%mend;    
%epa(20080101,20081231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2008 data=x1 force; run;
  %end;
%mend;    
%epa(20080101,20081231);
*Year 2009;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2009 data=x1 force; run;
  %end;
%mend;    
%epa(20090101,20091231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2009 data=x1 force; run;
  %end;
%mend;    
%epa(20090101,20091231);
*Year 2010;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2010 data=x1 force; run;
  %end;
%mend;    
%epa(20100101,20101231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2010 data=x1 force; run;
  %end;
%mend;    
%epa(20100101,20101231);
*Year 2011;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2011 data=x1 force; run;
  %end;
%mend;    
%epa(20110101,20111231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2011 data=x1 force; run;
  %end;
%mend;    
%epa(20110101,20111231);
*Year 2012;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2012 data=x1 force; run;
  %end;
%mend;    
%epa(20120101,20121231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2012 data=x1 force; run;
  %end;
%mend;    
%epa(20120101,20121231);
*Year 2013;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2013 data=x1 force; run;
  %end;
%mend;    
%epa(20130101,20131231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2013 data=x1 force; run;
  %end;
%mend;    
%epa(20130101,20131231);
*Year 2014;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2014 data=x1 force; run;
  %end;
%mend;    
%epa(20140101,20141231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2014 data=x1 force; run;
  %end;
%mend;    
%epa(20140101,20141231);
*Year 2015;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2015 data=x1 force; run;
  %end;
%mend;    
%epa(20150101,20151231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2015 data=x1 force; run;
  %end;
%mend;    
%epa(20150101,20151231);
*Year 2016;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2016 data=x1 force; run;
  %end;
%mend;    
%epa(20160101,20161231);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2016 data=x1 force; run;
  %end;
%mend;    
%epa(20160101,20161231);
*Year 2017;
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=substr(ip,1,6);
    if nip in:('134.67','161.80','204.46','204.47');
  run;
  proc append base=x2017 data=x1 force; run;
  %end;
%mend;    
%epa(20170101,20170630);
%macro epa(begdate,enddate);
  %do date=&begdate %to &enddate;
  data x1;
    set data.log&date;
    nip=compress(ip,'','a');
    if nip in:('12.1.123.','192.58.247.');
  run;
  proc append base=x2017 data=x1 force; run;
  %end;
%mend;    
%epa(20170101,20170630);
data database.EPAEdgar;
format extention $50.;
set x2003 x2004 x2005 x2006 x2007 x2008 x2009 x2010 x2011 x2012 x2013 x2014 x2015 x2016 x2017;
run;
