Hello everyone! I am not sure if it is possible, but I have the code below that is producing the output to rtf in the image attached titled capture. I am wanting to produce the second image (capture2) with a boarder between column groups. If this is possible, can you point me in the direction of what I need to be looking for?
PROC TABULATE DATA=WORK.ENROLLED_DC S=[JUST=C]; VAR TOTAL; CLASS location / ORDER=UNFORMATTED MISSING; CLASS highSchoolName / ORDER=UNFORMATTED MISSING; TABLE /* ROW Statement */ highSchoolName={LABEL="" S=[CELLWIDTH=2.5in]} all = 'Total' , /* COLUMN Statement */ location={LABEL=""} *(TOTAL={LABEL=""} * N={LABEL="#" S=[CELLWIDTH=.6IN]}*f=comma6. TOTAL={LABEL=""} * RowPctN={LABEL="%" S=[CELLWIDTH=.6IN]}*f=PCTFMT. ) all = 'Total' *(TOTAL={LABEL=""} * N={LABEL="#" S=[CELLWIDTH=.6IN]}*f=comma6. TOTAL={LABEL=""} * RowPctN={LABEL="%" S=[CELLWIDTH=.6IN]}*f=PCTFMT. ) ;; FORMAT location $LOCATION.; RUN; RUN; QUIT;
Sorry about the Total variable miss. I didn't see it as I NEVER put var statemets second and just couldn't see it...
Since I don't have your data this produces what I think your looking for.
Note that use of LABEL can affect what the styles are applied to.
ods html style=rtf;
data work.class;
set sashelp.class;
total=1;
run;
proc tabulate data=work.class;
class age;
class sex;
classlev sex /s= [borderleftwidth=1 borderleftcolor=black borderleftstyle=solid];
var total;
keyword n / s=[borderleftwidth=1 borderleftcolor=black borderleftstyle=solid];
table age all='Total',
sex="" *Total="" *
(n="#"*{ S=[borderleftwidth=1 borderleftcolor=black borderleftstyle=solid CELLWIDTH=.6IN]}*f=comma6.
rowpctn="%"*{ S=[CELLWIDTH=.6IN]})
all={label='Total' s=[ borderleftwidth=1 borderleftcolor=black borderleftstyle=solid]}*Total="" *
(n="#"*{ S=[borderleftwidth=1 borderleftcolor=black borderleftstyle=solid CELLWIDTH=.6IN]}*f=comma6.
rowpctn="%"*{ S=[CELLWIDTH=.6IN]})
/misstext=' ';
run;
You might want to use a macro variable to hold the common style elements to make the code a tad easier to read and modify since the same code has to appear in different places to address the border of the Class variable, the header for the statistic and the tabled values.
Which ODS style and destination are you using?
I'm not quite sure I believe that your posted tabulate code creates the first example. You have TOTAL in several places that I would expect to generate an error of undefined variable (Class or Var).
I am using the following style and destination code:
ods rtf file="\\PATH\SUMMARY.RTF" startpage=no;
And yes, that code did create the output in the picture. The TOTAL you are seeing is a variable named 'TOTAL', not total in the sense of a calcuation. The variable TOTAL is what we use in our office for a variable that always =1 to do our calcuations on.
Sorry about the Total variable miss. I didn't see it as I NEVER put var statemets second and just couldn't see it...
Since I don't have your data this produces what I think your looking for.
Note that use of LABEL can affect what the styles are applied to.
ods html style=rtf;
data work.class;
set sashelp.class;
total=1;
run;
proc tabulate data=work.class;
class age;
class sex;
classlev sex /s= [borderleftwidth=1 borderleftcolor=black borderleftstyle=solid];
var total;
keyword n / s=[borderleftwidth=1 borderleftcolor=black borderleftstyle=solid];
table age all='Total',
sex="" *Total="" *
(n="#"*{ S=[borderleftwidth=1 borderleftcolor=black borderleftstyle=solid CELLWIDTH=.6IN]}*f=comma6.
rowpctn="%"*{ S=[CELLWIDTH=.6IN]})
all={label='Total' s=[ borderleftwidth=1 borderleftcolor=black borderleftstyle=solid]}*Total="" *
(n="#"*{ S=[borderleftwidth=1 borderleftcolor=black borderleftstyle=solid CELLWIDTH=.6IN]}*f=comma6.
rowpctn="%"*{ S=[CELLWIDTH=.6IN]})
/misstext=' ';
run;
You might want to use a macro variable to hold the common style elements to make the code a tad easier to read and modify since the same code has to appear in different places to address the border of the Class variable, the header for the statistic and the tabled values.
That worked perfectly, thank you so much!
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.