Hello everyone, I also refer to the thread How to use a variable with a SAS name literal as its name in a TABULATE procedure? The code below apparently always causes an error in the TABLE statement of a PROC TABULATE when a SAS name literal of the form "..."N or '...'N is used, where an upper case letter N immediately follows after the right quotation mark. This is in contrast to a SAS name literal of the form "..."n or '...'n, with the right quotation mark immediately followed by a lower case letter n. Nevertheless, the code below runs with an ending small n as well as with an ending capital N without any problems in the data steps: %MACRO T(D);
%LET I = %EVAL(&I + 1);
%DO J = 1 %TO 2; %LET V = %SCAN(I D, &J); %PUT (%NRSTR(&)&V) = (&&&V); %END;
DATA Test&I; &D = &I;
PROC TABULATE DATA = Test&I; CLASS &D; TABLE &D; RUN;
%MEND T;
%LET I =;
%T("..."n)
%T('...'n)
%T(%SYSFUNC(QUOTE(...))n)
%T(%SYSFUNC(CATQ(A2N, ...)))
%T(%SYSFUNC(CATQ(A1N, ...)))
%T("..."N)
%T('...'N)
%T(%SYSFUNC(QUOTE(...))N)
%T(%SYSFUNC(NLITERAL(...))) Here's what appears in the log when I launch the code: 13 ODS _ALL_ CLOSE;
14 OPTIONS DEV=SVG;
15 GOPTIONS XPIXELS=0 YPIXELS=0;
16 %macro HTML5AccessibleGraphSupported;
17 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
18 %mend;
19 FILENAME EGHTML TEMP;
20 ODS HTML5(ID=EGHTML) FILE=EGHTML
21 OPTIONS(BITMAP_MODE='INLINE')
22 %HTML5AccessibleGraphSupported
23 ENCODING='utf-8'
24 STYLE=HTMLBlue
25 NOGTITLE
26 NOGFOOTNOTE
27 GPATH=&sasworklocation
28 ;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
29
30 %MACRO T(D);
31 %LET I = %EVAL(&I + 1);
32 %DO J = 1 %TO 2; %LET V = %SCAN(I D, &J); %PUT (%NRSTR(&)&V) = (&&&V); %END;
33 DATA Test&I; &D = &I;
34 PROC TABULATE DATA = Test&I; CLASS &D; TABLE &D; RUN;
35 %MEND T;
36
37 %LET I =;
38 %T("..."n)
(&I) = (1)
(&D) = ("..."n)
NOTE: The data set WORK.TEST1 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: There were 1 observations read from the data set WORK.TEST1.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.07 seconds
cpu time 0.04 seconds
39 %T('...'n)
(&I) = (2)
2 The SAS System 16:10 Friday, November 17, 2023
(&D) = ('...'n)
NOTE: The data set WORK.TEST2 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
NOTE: There were 1 observations read from the data set WORK.TEST2.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
40 %T(%SYSFUNC(QUOTE(...))n)
(&I) = (3)
(&D) = ("..."n)
NOTE: The data set WORK.TEST3 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: There were 1 observations read from the data set WORK.TEST3.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
41 %T(%SYSFUNC(CATQ(A2N, ...)))
(&I) = (4)
(&D) = ("..."n)
NOTE: The data set WORK.TEST4 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: There were 1 observations read from the data set WORK.TEST4.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.04 seconds
cpu time 0.01 seconds
42 %T(%SYSFUNC(CATQ(A1N, ...)))
(&I) = (5)
(&D) = ('...'n)
NOTE: The data set WORK.TEST5 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
3 The SAS System 16:10 Friday, November 17, 2023
NOTE: There were 1 observations read from the data set WORK.TEST5.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.06 seconds
cpu time 0.04 seconds
43 %T("..."N)
(&I) = (6)
(&D) = ("..."N)
NOTE: The data set WORK.TEST6 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
ERROR: The type of name ('..."'n) is unknown.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
44 %T('...'N)
(&I) = (7)
(&D) = ('...'N)
NOTE: The data set WORK.TEST7 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
ERROR: The type of name ('...'''n) is unknown.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
45 %T(%SYSFUNC(QUOTE(...))N)
(&I) = (8)
(&D) = ("..."N)
NOTE: The data set WORK.TEST8 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
ERROR: The type of name ('..."'n) is unknown.
4 The SAS System 16:10 Friday, November 17, 2023
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
46 %T(%SYSFUNC(NLITERAL(...)))
(&I) = (9)
(&D) = ("..."N)
NOTE: The data set WORK.TEST9 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: The type of name ('..."'n) is unknown.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
47
48 %LET _CLIENTTASKLABEL=;
49 %LET _CLIENTPROCESSFLOWNAME=;
50 %LET _CLIENTPROJECTPATH=;
51 %LET _CLIENTPROJECTPATHHOST=;
52 %LET _CLIENTPROJECTNAME=;
53 %LET _SASPROGRAMFILE=;
54 %LET _SASPROGRAMFILEHOST=;
55
56 ;*';*";*/;quit;run;
57 ODS _ALL_ CLOSE;
58
59
60 QUIT; RUN;
61 Is there an explanation for the resulting errors? ERROR: The type of name ('..."'n) is unknown. ERROR: The type of name ('...'''n) is unknown. Just to be perfectly clear, I hereby report that the following code, in which I only replaced &D in the TABLE statement by %SYSFUNC(LOWCASE(&D)), does not cause any errors: %MACRO T(D);
%LET I = %EVAL(&I + 1);
%DO J = 1 %TO 2; %LET V = %SCAN(I D, &J); %PUT (%NRSTR(&)&V) = (&&&V); %END;
DATA Test&I; &D = &I;
PROC TABULATE DATA = Test&I; CLASS &D; TABLE %SYSFUNC(LOWCASE(&D)); RUN; /* &D in the TABLE statement was replaced by %SYSFUNC(LOWCASE(&D)). */
%MEND T;
%LET I =;
%T("..."n)
%T('...'n)
%T(%SYSFUNC(QUOTE(...))n)
%T(%SYSFUNC(CATQ(A2N, ...)))
%T(%SYSFUNC(CATQ(A1N, ...)))
%T("..."N)
%T('...'N)
%T(%SYSFUNC(QUOTE(...))N)
%T(%SYSFUNC(NLITERAL(...))) Thanks in advance. Kind regards, Peter
... View more