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?
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
Looks like a bug in the TABLE statement of PROC TABULATE. Open a support ticket with SAS support.
Perhaps the garbled name it writes in the error message will help them debug what is happening.
1068 PROC TABULATE DATA = Test6; 1069 CLASS "..."N; 1070 TABLE "..."N; 1071 RUN; 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 1072 1073 PROC TABULATE DATA = Test6; 1074 CLASS "..."n; 1075 TABLE "..."N; 1076 RUN; 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 1077 1078 PROC TABULATE DATA = Test6; 1079 CLASS "..."N; 1080 TABLE "..."n; 1081 RUN; NOTE: There were 1 observations read from the data set WORK.TEST6. NOTE: PROCEDURE TABULATE used (Total process time): real time 0.03 seconds cpu time 0.00 seconds
Whoah! You found a bug with a proc that exists since a long time.
I could confirm what you observe both under SAS9.4M7 under Windows and SAS Viya 4 under RHEL both for compute and CAS.
Below my Viya testing - might be worth sharing with SAS Tech Support that this is still an issue under Viya.
cas mysess cassessopts=(caslib="casuser");
libname casuser cas;
data casuser.class;
set sashelp.class;
run;
proc tabulate data=casuser.class;
class 'name'n;
table 'name'n;
run;
proc tabulate data=casuser.class;
class 'name'N;
table 'name'N;
run;
proc tabulate data=sashelp.class;
class 'name'n;
table 'name'n;
run;
proc tabulate data=sashelp.class;
class 'name'N;
table 'name'N;
run;
80 cas mysess cassessopts=(caslib="casuser"); NOTE: 'CASUSER(*********)' is now the active caslib. NOTE: The CAS statement request to update one or more session options for session MYSESS completed. 81 82 libname casuser cas; NOTE: Libref CASUSER was successfully assigned as follows: Engine: CAS Physical Name: **** 83 84 data casuser.class; 85 set sashelp.class; 86 run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: The data set CASUSER.CLASS has 19 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.02 seconds 87 88 proc tabulate data=casuser.class; 89 class 'name'n; 90 table 'name'n; 91 run; NOTE: The CAS aggregation.aggregate action will be used to perform the initial summarization. NOTE: The PROCEDURE TABULATE printed pages 9-10. NOTE: PROCEDURE TABULATE used (Total process time): real time 0.06 seconds cpu time 0.03 seconds 92 93 proc tabulate data=casuser.class; 94 class 'name'N; 95 table 'name'N; 96 run; ERROR: The type of name ('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 97 98 proc tabulate data=sashelp.class; 99 class 'name'n; 100 table 'name'n; 101 run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: The PROCEDURE TABULATE printed pages 11-12. NOTE: PROCEDURE TABULATE used (Total process time): real time 0.01 seconds cpu time 0.03 seconds 102 103 proc tabulate data=sashelp.class; 104 class 'name'N; 105 table 'name'N; 106 run; ERROR: The type of name ('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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.