Hi,
I used the following code to get SAS output in Excel. Variable" Location " is already formatted. "By location" is used to create a seperate table for each location. Attached is the example for one of the tables created.You can see everything else (title, data, headers, ect) are in the right style (Times New Roman, 10pt) except for the text "LOCATION=Distance Education". Is there any way to change the style of "LOCATION=Distance Education" so it has Times New Roman as Font_Face and 10pt as Font_Size?
proc template;
define style styles.newstyle;
parent = styles.minimal;
style data/
background = white
foreground = black
font_style = Roman
font_weight = medium
font_size = 10pt
font_face = "Times New Roman"
textalign=center
verticalalign=middle;
style header/
background = white
foreground = black
font_style = Roman
font_weight = medium
font_size = 10pt
font_face = "Times New Roman";
style systemtitle/
background = white
foreground = black
font_style = Roman
font_weight = medium
font_size = 10pt
font_face = "Times New Roman"
style table/
cellspacing=0
cellpadding=7
FRAME=BOX
RULES=all
borderwidth = 1pt
END;
RUN;
ODS TAGSETS.EXCELXP FILE='C:\xxx\ODSOUTPUT.XML'
STYLE=newstyle OPTIONS (sheet_interval='none' sheet_name='TEST' embedded_titles='on' FITTOPAGE='YES' ORIENTATION='LANDSCAPE');
PROC TABULATE DATA=xxx MISSING ORDER=FORMATED;
CLASS FP TERM_CODE location;
TABLE FP=' ' ALL='Total',
TERM_CODE=' '*(N='#'*F=COMMA6. PCTN<FP ALL>='%'*F=COMMA6.1);
FORMAT LOCATION LOCATION. TERM_CODE $TERM.;
BY LOCATION;
run;
ODS TAGSETS.EXCELXP CLOSE;
In Proc tabulate I would not use BY for most things. Instead use that variable in the Page position of the table and style overrides instead of trying to find the esoteric items that may be needed for BY lines in a style
PROC TABULATE DATA=xxx MISSING ORDER=FORMATED; CLASS FP TERM_CODE location; TABLE Location *style=[style options like font and size], FP=' ' ALL='Total', TERM_CODE=' '*(N='#'*F=COMMA6. PCTN<FP ALL>='%'*F=COMMA6.1) ; FORMAT LOCATION LOCATION. TERM_CODE $TERM.; run;
I don't use the page options often so originally supplied something based on anothe example I have.
You would place the options for the Page variable Location in the Class statement
Class location / style=[fontfamily='Times New Roman' just=c];
and remove Location from the other class statement an the style override from the table statement.
I am not sure if you are requesting to have the text for location in red or not. If so add Color=red to the style elements in the class statement.
Notice that the options are Fontfamily FontSize Fontstyle Fontweight and Fontwidth to address font characteristics.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.