I want to write a macro that run an append the result of 10 queries, which I generate with SAS macro code.
%MACRO APPENDTEST;
PROC SQL;
%DO I = 1 %TO 12
CREATE TABLE WORK.APPENDTEST AS
SELECT t1.OrderID, t2.Name, t3.Product, t1.Date, t1.Units
FROM DVJAYESH.CANDY_SALES_HISTORY t1,
DVJAYESH.CANDY_PRODUCTS t3,
DVJAYESH.CANDY_CUSTOMERS t2
WHERE (t1.ProdID = t3.ProdID AND t1.Customer = t2.CustID)
AND t1.Date BETWEEN CATS('01', %PUT(CATS(&I), $MTH_NAME.), '2003')D AND
CATS('31', %PUT(CATS(&I), $MTH_NAME.), '2003')D
ORDER BY t1.Date, t2.Name, t3.Product;
%END;
QUIT;
%MEND APPENDTEST;
%APPENDTEST;
I get multiple errors. The first one is - A character operand was found in the %EVAL function or %IF condition where a numeric operand is required.
Please explain and correct.
FYI: I am Very new to SAS Programming. I use SAS ENTERPRISE GUIDE
year(t1.date)=2003 and month(date)=&I.
? Also, you'd need to put&I
in the table name or it will just overwrite the same data set each time it runs. – DWal