BookmarkSubscribeRSS Feed
RichardDeVen
Barite | Level 11

Is there a way to top align data cells in ODS EXCEL using a custom style with a STYLE or CLASS override?

 

In this example I can set the font to be 10pt Arial, don't know how to top align.

 

dm 'clear log' log;

proc template;
  source styles.default;
  source styles.statistical;
  define style special;
  parent = styles.statistical;
  style fonts from fonts /
    'HeadingFont'= ('Arial', 10pt, bold)
    'DocFont'    = ('Arial', 10pt)
  ;
  end;
run;

ods excel 
  file="special%sysfunc(monotonic()).xlsx" 
  style=special 
  options(
    zoom='85'
    row_heights='15,25'
  )
;

proc print noobs label data=sashelp.class;
run;

ods excel close;

 

RichardADeVenezia_0-1633543405512.png

 

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  These worked for me without changing any suboptions for ODS Excel.

1) Using Style overrides:

Cynthia_sas_1-1633544596308.png

 

2) Using PROC Template:

Cynthia_sas_2-1633544635931.png

(I only changed the header cells. If you want to top align the data cells too, you'd need a style override for style(column) in PROC REPORT and for style(data) in PROC PRINT. Inside the style template, you'd use CLASS data in addition to CLASS header.)

Cynthia

ballardw
Super User

The default cell sizes may not allow for changes in justification so you may need to make the cells taller first.

This changes the column headings as well as the body of the table using Proc Print. Proc Print will make all the cells the same height, largest if you specify multiple different heights.

 

proc print data=sashelp.class;
  var name / style=[vjust=top height=.5in];
  var sex  / style=[vjust=center ];
  var age height weight / style=[vjust=bottom ];
run;
RichardDeVen
Barite | Level 11

Thanks for the replies.

 

Turns out the template statement needed is:

  style data from data /
    VerticalAlign = Top
  ;
  end;

I had tried name value pair in quotes. "VerticalAlign"="Top"

Cynthia_sas
SAS Super FREQ
Hi:
VJUST=T will also work. or VERTICALALIGN=T. Typically, the only style attributes that need to be quoted are text strings (like for Table of Contents) or font names which contain spaces, or a string of font family specifications.
Cynthia

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1162 views
  • 0 likes
  • 3 in conversation