DATA Step, Macro, Functions and more

How to left align the text in Proc Means output?

Accepted Solution Solved
Reply
Super Contributor
Posts: 335
Accepted Solution

How to left align the text in Proc Means output?

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?  

 

SAS forum.png

 

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;

 

 

 


Accepted Solutions
Solution
‎08-30-2017 01:22 PM
SAS Super FREQ
Posts: 497

Re: How to left align the text in Proc Means output?

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;

View solution in original post


All Replies
Solution
‎08-30-2017 01:22 PM
SAS Super FREQ
Posts: 497

Re: How to left align the text in Proc Means output?

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;
Super Contributor
Posts: 335

Re: How to left align the text in Proc Means output?

Posted in reply to WarrenKuhfeld

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;

 

SAS Super FREQ
Posts: 497

Re: How to left align the text in Proc Means output?

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;
Super User
Posts: 13,321

Re: How to left align the text in Proc Means output?

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 266 views
  • 3 likes
  • 3 in conversation