I have a requirement to pull millions of data for more than 10,000 Ids at an event level for the last few years. I tried to use SAS macro to pull the data for each month however the query fails due to some threshold limits on the tables
Data looks like this
ID Date amount seq
101 1/15/2015 $100 a101
101 1/17/2017 $100 b101
101 3/15/2018 $50 c101
101 3/21/2018 $200 d101
.......................
.......................
20001 2/15/2022 $100 a20001
20001 3/18/2022 $10 b20001
My query
%macro data(no,Start,End);
proc sql;
create table AllDataPoints as
select * from connection to Teradata
(
select dsitinct Id, seq, date, amount
from table
where date between &start and &end
);
quit;
%mend;
%data(1,'2015-01-01','2015-01-31');
%data(2,'2015-02-01','2015-02-28');
...
...
%data(12,'2015-12-01','2015-12-31');
I would repeat this for years 2015 thru 2022 but query fails due to some table limitations.
Is there a way I can write a loop macro to repeat this for each day and later append all the data?
Thanks
If you wanted to do it by day, you can modify your macro as follows:
The only change you need to make is to not use quotes when specifying your start/end dates, and specify a final output dataset.