I'd like to use proc means' output directly as a PDF file. For more visually appealing purpose, I wonder if i could left align the column label and the title in the final output as shown in image WANT below?
proc means data=have stackods n maxdec=0;
class fac;
var a1-a17;
ods output summary=result(drop=NObs _control_ where=(N ne 0));
run;
proc print data=result label noobs;
label variable='Birth Defect Types';
label n='Total number of defects';
label op_fac_name='Facility name';
format variable $group.;
title "FIRST INCIDENCE";
run;
There is a style option in proc print. More generally, you can change the justification in the table template.
proc means data=sashelp.class stackods n maxdec=0;
class sex;
var _numeric_;
ods output summary=result(drop=NObs _control_ where=(N ne 0));
run;
proc print data=result label noobs style(header)={just=l};
label variable='Birth Defect Types';
label n='Total number of defects';
label op_fac_name='Facility name';
* format variable $group.;
title "FIRST INCIDENCE";
run;
There is a style option in proc print. More generally, you can change the justification in the table template.
proc means data=sashelp.class stackods n maxdec=0;
class sex;
var _numeric_;
ods output summary=result(drop=NObs _control_ where=(N ne 0));
run;
proc print data=result label noobs style(header)={just=l};
label variable='Birth Defect Types';
label n='Total number of defects';
label op_fac_name='Facility name';
* format variable $group.;
title "FIRST INCIDENCE";
run;
Great ways to align the labels. Thank you. Do you know why "by descending" in proc sort has no effect in the proc sort? Does proc print "style" options override previous options set forth?
proc means data=have stackods n maxdec=0;
class op_fac_name;
var a1-a17;
ods output summary=fac_types(drop=NObs _control_ where=(N ne 0));
run;
proc sort data=fac_types;
by descending op_fac_name n;
run;
proc print data=fac_types label noobs style(header)={just=l};
label variable='Defect Types';
label n='Total number of defects';
label op_fac_name='Facility name';
format variable $group.;
title "FIRST INCIDENCE";
run;
Descending certainly works. Here is an example.
proc sort data=sashelp.class out=c1;
by descending sex;
run;
proc print; run;
proc sort data=sashelp.class out=c2;
by descending sex descending height;
run;
proc print; run;
Another option may be to set column widths so you don't have to deal with the offest on the second line of a column heading at all.
Below is syntax example and may not have optimal widths due to your current style but should be easy to adjust.
proc print data=result label noobs style(header)={just=l}; var op_fac_name / style=[width=1.25in]; var variable / style=[width=1.5in]; var n / style=[width=1.75in]; label variable='Birth Defect Types'; label n='Total number of defects'; label op_fac_name='Facility name'; * format variable $group.; title "FIRST INCIDENCE"; run;
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.