Hi,
i have create this sas macro:
%MACRO MACROFILTRO (TABELLA=, OWNER= );
PROC SQL;
CREATE TABLE ATM.T7_D_ELENCO_TERMINALI_IMP AS
SELECT * FROM ATM.T7_D_ELENCO_TERMINALI_IMP
UNION ALL
SELECT C.*, B.IM_TOT_CARIC, B.CO_ID_OLI
FROM ATM.T7_D_ELENCO_TERMINALI_VER1 A
INNER JOIN ATM.T01C_CANONI C ON (A.KEYATM = C.KEYATM)
LEFT JOIN &OWNER..MOANAATM_&TABELLA B ON (A.KEYATM = B.KEYATM) /* 1° 102015 2° 082015 3° 062015 4* 042015 5° 022015 6° 012015 7°122014 8° 112014 9°062014 10° 012014 11° 082013*/
WHERE B.KEYATM IS NOT NULL
;
quit;
%MEND MACROFILTRO;
%MACROFILTRO(TABELLA=%Str(102015), OWNER= %Str(TERM) );
why i have this error ?
1780 WHERE B.KEYATM IS NOT NULL
1781 ;
1782 quit;
1783
1784 %MEND MACROFILTRO;
1785 %MACROFILTRO(TABELLA=%Str(102015), OWNER= %Str(TERM) );
NOTE: Line generated by the macro variable "TABELLA".
1 TERM.MOANAATM_102015
------
22
------
200
ERROR 22-322: Syntax error, expecting one of the following: a name, (, AS, ON.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
Thanks!!!!!!!!!!!!!!!!!!!
SQL parses statements a little differently. Try it this way:
%unquote(&OWNER..MOANAATM_&TABELLA)
SQL parses statements a little differently. Try it this way:
%unquote(&OWNER..MOANAATM_&TABELLA)
Hi,
I know you have your answer but I wanted to throw a few things in there:
Firstly, why the macro in the first place, it doesn't seem to add anything. Try not to obfuscate code for no reason.
- Try to avoid coding all in upper case, it makes reading code very hard. I know SQL tends to put variables and tabes in uppercase, which is fine. See below an example.
Finally, why are you union all data from the table and some other data? Why not just insert the additional data into the existing dataset? Again, example below:
proc sql; insert into ATM.T7_D_ELENCO_TERMINALI_IMP select C.*, B.IM_TOT_CARIC, B.CO_ID_OLI from ATM.T7_D_ELENCO_TERMINALI_VER1 A inner join ATM.T01C_CANONI C on A.KEYATM=C.KEYATM left join TERM.MOANAATM_102015 B on A.KEYATM=B.KEYATM where B.KEYATM IS NOT NULL; quit;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.