Hi,
I had asked a question about indenting using proc tabulate in my last post and i am using the same data here. I am trying to get some formatted templates that you might have used for exporting results to excel. All ideas are welcome. Thanks!
data testing;
input Name $ County $ MaxRun MinRun RUNS FIRSTD LASTD TIME Reduce $ Increase $;
datalines;
A X 5 2 4 130 135 122 No Yes
A X 5 2 4 870 885 122 No Yes
B Y 7 1 7 660 610 220 Yes No
B Y 7 1 7 660 610 220 Yes No
B Z 7 1 7 660 610 220 Yes No
C Z 3 1 5 485 430 220 Yes No
C X 4 1 4 195 190 220 Yes No
C X 4 1 4 195 190 220 Yes No
D Y 5 1 5 575 485 106 Yes No
D Y 5 1 5 800 795 106 Yes No
D Z 6 3 3 103 106 210 No Yes
A Z 6 1 6 590 585 210 Yes No
A X 9 1 9 835 870 210 No Yes
B X 9 1 9 835 870 210 No Yes
C Y 2 2 1 165 165 620 No No
C Y 1 3 9 112 535 234 Yes No
C Z 1 3 9 112 535 234 Yes No
;
/*Summary for quantitative variables*/
ODS TAGSETS.EXCELXP
file="path\check info.xml"
STYLE=statistical
OPTIONS (embedded_titles='yes' embedded_footnotes='yes' FitToPage = 'yes'
sheet_name="Quantitative" Orientation = 'landscape');
title "Quant Table";
proc tabulate data= Testing format=comma11.2;
CLASS county;
var MaxRun MinRun RUNS FIRSTD LASTD TIME;
table County * (MaxRun='Maximum Runs' MinRun='Minimum Runs' RUNS='RUNS' FIRSTD='1st' LASTD='Lst' TIME='TT'),(N mean*f=9.1 median*f=9.1 std*f=9.2)/rts=25 INDENT=4;
keylabel ALL = 'Total'
mean = 'Mean'
median = 'Median'
std = 'SD';
run;
/*Summary for categorical variables*/
STYLE=statistical
OPTIONS (embedded_titles='yes' embedded_footnotes='yes' FitToPage = 'yes'
sheet_name="Categorical" Orientation = 'landscape');
title "Categorical Table";
proc tabulate data= testing NOSEPS format=comma11.2;
class Reduce Increase/ missing;
table (Reduce='' Increase=''), (all pctn)/rts=25 INDENT=4;
keylabel
pctn = '%';
run;
ods tagsets.ExcelXP close;
ods html close;
run;
I'm not sure if this would be helpful for you or not, but I have a macro dedicated to summarizing different types of data and outputting to different locations (like ODS EXCEL). There is an article here: https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-...
I ran the following on your example data set and got the attached EXCEL file.
%tablen(data=testing, by=county, showpval=0,
var=maxrun minrun runs firstd lastd time reduce increase,type=1 1 1 1 1 1 2 2,
shading=2,outdoc=~/ibm/test.xlsx,destination=excel);
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.