0

I'm generating tables with rolling weeks of data, so my columns have to be named in the yyyymmdd format like 20161107. I need to apply a comma format to these columns to display counts, but the format is also being applied to the column name so 20161107 turns into 20,161,107. Below is example code that shows the error:

data fish; set sashelp.fish; 
    TEST = WIDTH*1000;
run;

ods tagsets.excelxp file = "C:\User\Desktop\test.xls" style=minimal
    options(embedded_titles="yes" autofit_height="yes" autofilter="all");

proc report data = fish spanrows nowd &header_style.;
    column SPECIES TEST;
    define SPECIES / display;
    define TEST / display "20161107" 
        f=comma12. style={tagattr='format:###,###,###'}; /* ERROR OCCURS WITH THIS STYLE */
    title1 bold "sashelp.fish title";
run; title1;

ods tagsets.excelxp close;

It looks like I can fix this error by padding the display name with spaces like " 20161107 " but I'm not hardcoding these names, so I'd like to try to fix it in the proc report syntax first if possible. Any insight?

kstats9pt3
  • 799
  • 2
  • 8
  • 28

1 Answers1

0

You should tell SAS to only apply that style to the column, then:

define TEST / display "20161107" 
    f=comma12. style(column)={tagattr='format:###,###,###'}; 

Then it should work as you expect.

Styles in PROC REPORT typically have multiple things they can apply to, and if you don't specify which they apply to all. style(header), style(report), etc. are all options - you can see the full list, plus a good explanation, in the SAS paper Using Style Elements in the REPORT and TABULATE procedures.

Joe
  • 62,789
  • 6
  • 49
  • 67