Hi,
I am very new to SAS.
I have just tried to write a macro for pulling 2 years transaction data hitting the teradata DB. I had pulled monthly basis just for better performance on DB side.
I have combined all the datasets into a single at the end using proc append.
Following is the code:
%macro pull (bdate,edate,mthrange);
proc sql;
connect to oracle (user=zzzzzz pw=yyyyyy server=xxx);
create table in.data_&mthrange. as
select * from connection to teradata;
(
select * from trans_table
where trans_dt between &bdate and &edate
);
disconnect from teradata;
quit;
%mend pull;
%pull('2008-03-02','2008-05-31',Mar08_May08);
%pull('2008-06-01','2008-08-30',Jun08_Aug08);
%pull('2008-08-31','2008-10-04',Sep08);
%pull('2008-10-05','2008-11-04',Oct08);
%pull('2008-11-02','2008-11-29',Nov08);
%pull('2008-11-30','2009-01-03',Dec08);
%pull('2009-01-04','2009-02-28',Jan09_Feb09);
%pull('2009-03-01','2009-05-30',Mar09_May09);
%pull('2009-05-31','2009-08-29',Jun09_Aug09);
%pull('2009-08-30','2009-10-03',Sep09);
%pull('2009-10-04','2009-10-31',Oct09);
%pull('2009-11-01','2009-11-28',Nov09);
%pull('2009-11-29','2010-01-02',Dec09);
%pull('2010-01-03','2010-02-27',Jan10_Feb10);
%macro append(range);
proc append base=in.data data=in.data_&range.;
run;
%mend append;
%append(Mar08_May08);
%append(Jun08_Aug08);
%append(Sep08);
%append(Oct08);
%append(Nov08);
%append(Dec08);
%append(Jan09_Feb09);
%append(Mar09_May09);
%append(Jun09_Aug09);
%append(Sep09);
%append(Oct09);
%append(Nov09);
%append(Dec09);
%append(Jan10_Feb10);
Problem:- it is occupying space twice. as the Final dataset is the combined one. I used to delete the intermediate datasets after verifying the sum of counts of all the intermediate datasets to the final one. I just wanted to do that step programmatically in such a way that after each append its verying the counts and if success deleting the verified datasets and then going to the next step of combining. Also, in case the counts doesnot match it should throw an errror.
Please let me know the best possible solution for this.
Message was edited by: sohit