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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.