I am currently having trouble using an incrementing data range to output a table that uses a table filled with Emails with JobOffers that have already been renamed using VBA - this is more for my own learning than anything else.
I want the code to loop through the days I can set in a macro command
%EmailDump('01Jan2015'd,'02Jan2015')
And it will run the Macro in the code below and allow me to pull back all emails from within that period and export it (I understand I am over writing the table each time - however this will be exported (each export should be different because it has the macro for EmailStart within it)
So some dummy data for this would look like
Topic EmailStartDate
Job Offer 12/01/2015
Job Offer 25/01/2015
Job Offer 12/05/2015
The Code used is the below
%Macro EmailDump(begindate,endindate);
%do
EmailStart = &begindate.
%to &endindate.
%by 1;
%end;
PROC SQL;
CREATE TABLE WORK.EMAILDUMP AS
SELECT * FROM WORK.EMAILS
WHERE TOPIC = 'JobOffer'
and EmailStartDate = &EmailStart
;QUIT;
proc export data=work.EMAILDUMP
dbms=XLSX
outfile="/p01/Output File &EmailStart " replace;
run;
%Mend EmailDump;
%EmailDump('01Jan2015'd,'02Jan2015'd);
The error message looks like the below
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &begindate. ERROR: The %FROM value of the %DO EmailStart loop is invalid. ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &endindate. ERROR: The %TO value of the %DO EmailStart loop is invalid. ERROR: The macro EmailDump will stop executing
Not sure if anyone can help me with this? Would much appreciate any help!