Hi,
I'm trying to use the excel text format [tagattr="format:@"] in the column ID_NACIONAL but I noticed the format is applied to the columns definition even I didn't create the style element in that section. I've tried to put the statement in other sections of the code but I don't get to make it works fine.
PROC TABULATE
DATA=WORK.MCR_CONSULTA
;
VAR IDRazon MONTO;
CLASS DescRazon / ORDER=UNFORMATTED MISSING;
CLASS NOMBRE_DEM / ORDER=UNFORMATTED MISSING style=[width=2.5in];
CLASS ID_NACIONAL / ORDER=UNFORMATTED MISSING;
CLASS "APLICA"n / ORDER=UNFORMATTED MISSING;
TABLE
/* ROW Statement */
NOMBRE_DEM * ID_NACIONAL = 'ID_NACIONAL' * [style=[tagattr="format:@"]] * "APLICA"n ,
/* COLUMN Statement */
DescRazon *(IDRazon=' ' * Sum=' ' MONTO=' ' * Sum=' ' )
all = 'Total' * [style=[background=lightgrey fontweight=bold]] * (IDRazon=' ' * Sum=' ' MONTO=' ' * Sum=' ' * f=dollar10. );
RUN;
Hello,
After many reading and investigation I've found the solution using classlev as follow:
PROC TABULATE
DATA=WORK.MCR_CONSULTA
;
VAR IDRazon MONTO;
CLASS DescRazon / ORDER=UNFORMATTED MISSING;
CLASS NOMBRE_DEM / ORDER=UNFORMATTED MISSING style=[width=2.5in];
CLASS ID_NACIONAL / ORDER=UNFORMATTED MISSING;
CLASSLEV ID_NACIONAL / S=[tagattr="format:@"];
CLASS "APLICA"n / ORDER=UNFORMATTED MISSING;
TABLE
/* ROW Statement */
NOMBRE_DEM * ID_NACIONAL = 'ID_NACIONAL' * "APLICA"n,
/* COLUMN Statement */
DescRazon *(IDRazon=' ' * Sum=' ' MONTO=' ' * Sum=' ' )
all = 'Total' * [style=[background=lightgrey fontweight=bold]] * (IDRazon=' ' * Sum=' ' MONTO=' ' * Sum=' ' * f=dollar10.);
RUN;CLASSLEV can be use to specify format to the values of a class variable.
There is an option on the Table statement in Proc Tabulate that might be related to your issue: FORMAT_PRECEDENCE. This option specifies the precedence of a format applied to a column, row or page controls and default is COLUMN.
I can't test anything as no example data was provided much less how the results are sent to Excel.
I would try changing:
all = 'Total' * [style=[background=lightgrey fontweight=bold]] * (IDRazon=' ' * Sum=' ' MONTO=' ' * Sum=' ' * f=dollar10. );
to
all = 'Total' * [style=[background=lightgrey fontweight=bold]]
* (IDRazon=' ' * Sum=' ' MONTO=' ' * Sum=' ' * f=dollar10. )
/ Format_Precedence=Row
;
the / starts table level options. I made the code a bit narrower so it was easier to read. I hate having to scroll horizontally to finish a line.
Hello,
After many reading and investigation I've found the solution using classlev as follow:
PROC TABULATE
DATA=WORK.MCR_CONSULTA
;
VAR IDRazon MONTO;
CLASS DescRazon / ORDER=UNFORMATTED MISSING;
CLASS NOMBRE_DEM / ORDER=UNFORMATTED MISSING style=[width=2.5in];
CLASS ID_NACIONAL / ORDER=UNFORMATTED MISSING;
CLASSLEV ID_NACIONAL / S=[tagattr="format:@"];
CLASS "APLICA"n / ORDER=UNFORMATTED MISSING;
TABLE
/* ROW Statement */
NOMBRE_DEM * ID_NACIONAL = 'ID_NACIONAL' * "APLICA"n,
/* COLUMN Statement */
DescRazon *(IDRazon=' ' * Sum=' ' MONTO=' ' * Sum=' ' )
all = 'Total' * [style=[background=lightgrey fontweight=bold]] * (IDRazon=' ' * Sum=' ' MONTO=' ' * Sum=' ' * f=dollar10.);
RUN;CLASSLEV can be use to specify format to the values of a class variable.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.