Hello, I am trying to troubleshoot a fairly simple macro logic. The code is here - %macro loop(values); /* Count the number of values in the string */ %let count=%sysfunc(countw(&values)); /* Loop through the total number of values */ %do i = 1 %to &count; %let value=%qscan(&values,&i); %put &value; PROC SQL; CREATE TABLE DEMOGRAPHICS_BASE_&VALUE AS (SELECT (COUNT ( DEMOGRAPHICS_BASE.DEMO_PARTICIPATING_USERS)) AS DEMO_PRTCPTNG_USERS ,DEMOGRAPHICS_BASE.DEMO_&VALUE._GROUPING FROM WORK.DEMOGRAPHICS_BASE AS DEMOGRAPHICS_BASE INNER JOIN WORK.DEMOGRAPHICS_BASE_100 AS DEMOGRAPHICS_BASE_100 ON (DEMOGRAPHICS_BASE.DEMO_PRCHSR_CODE = DEMOGRAPHICS_BASE_100.DEMO_PRCHSR_CODE) GROUP BY DEMOGRAPHICS_BASE.DEMO_&VALUE._GROUPING ); QUIT; %end; %mend; %loop(%str(AGE ETHN GDR)) Here is the log - MPRINT(LOOP): PROC SQL; SYMBOLGEN: Macro variable VALUE resolves to AGE SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. NOTE: Line generated by the invoked macro "LOOP". 56 PROC SQL; CREATE 56 ! TABLE DEMOGRAPHICS_BASE_&VALUE AS (SELECT (COUNT ( DEMOGRAPHICS_BASE.DEMO_PARTICIPATING_USERS)) AS DEMO_PRTCPTNG_USERS __ 202 ERROR 202-322: The option or parameter is not recognized and will be ignored. NOTE: Line generated by the macro variable "VALUE". 56 DEMOGRAPHICS_BASE_AGE ___ 78 SYMBOLGEN: Macro variable VALUE resolves to AGE SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. NOTE: Line generated by the macro variable "VALUE". 56 DEMOGRAPHICS_BASE.DEMO_AGE_GROUPING ___ _________ 22 202 SYMBOLGEN: Macro variable VALUE resolves to AGE SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. ERROR 78-322: Expecting a '.'. ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, AS, BETWEEN, CONTAINS, EQ, EQT, FORMAT, FROM, GE, GET, GT, GTT, IN, INFORMAT, INTO, IS, LABEL, LE, LEN, LENGTH, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, TRANSCODE, ^, ^=, |, ||, ~, ~=. ERROR 202-322: The option or parameter is not recognized and will be ignored. NOTE: Line generated by the macro variable "VALUE". 56 DEMOGRAPHICS_BASE.DEMO_AGE_GROUPING 3 The SAS System 10:10 Monday, July 18, 2011 ___ _________ 22 202 MPRINT(LOOP): CREATE TABLE DEMOGRAPHICS_BASE_AGE AS (SELECT (COUNT ( DEMOGRAPHICS_BASE.DEMO_PARTICIPATING_USERS)) AS DEMO_PRTCPTNG_USERS ,DEMOGRAPHICS_BASE.DEMO_AGE_GROUPING FROM AS DEMOGRAPHICS_BASE INNER JOIN WORK.DEMOGRAPHICS_BASE_100 AS DEMOGRAPHICS_BASE_100 ON (DEMOGRAPHICS_BASE.DEMO_PRCHSR_CODE = DEMOGRAPHICS_BASE_100.DEMO_PRCHSR_CODE) GROUP BY DEMOGRAPHICS_BASE.DEMO_AGE_GROUPING ); ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, ), *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, EXCEPT, GE, GET, GT, GTT, HAVING, IN, INTERSECT, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, OUTER, UNION, ^, ^=, |, ||, ~, ~=. ERROR 202-322: The option or parameter is not recognized and will be ignored. NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements. MPRINT(LOOP): QUIT; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds Memory 48k Page Faults 1 Page Reclaims 35 Page Swaps 0 Voluntary Context Switches 0 Involuntary Context Switches 1 Block Input Operations 0 Block Output Operations 0 SYMBOLGEN: Macro variable VALUES resolves to AGE ETHN GDR SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. SYMBOLGEN: Macro variable I resolves to 2 SYMBOLGEN: Macro variable VALUE resolves to ETHN SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. ETHN Note that both DEMOGRAPHICS_BASE_100 and DEMOGRAPHICS_BASE are working fine and are created prior to this macro. I am trying hard for several hours to pinpoint the bug but not able to do so. Appreciate any help Thanks, saspert
... View more