BookmarkSubscribeRSS Feed
NCNyrk
Calcite | Level 5
I am trying to create some very simple spreadsheets using HTML (XML output is too large) but would like to right-justify certain columns from a PROC PRINT. I've tried using .r style with HTMLCSS, but didn't get anywhere. Not sure what else to try...?
4 REPLIES 4
Cynthia_sas
Diamond | Level 26
Hi:
I tried this with ODS HTML3
[pre]
title; footnote;
ods html3 file='c:\temp\testjust_ht3.xls' style=sasweb;
proc print data=sashelp.class;
var name /style(data)={htmlstyle="text-align:right;" cellwidth=1in};
var age height;
run;
ods html3 close;
[/pre]

And when I opened the HTML 3.2 file with Excel, the Name was right-justified (I made the cellwidth bigger, so you could see the effect without enlarging the name column manually).

There must be some difference between HTML 3.2 (ODS HTML3) and the HTML generated by HTMLCSS (ODS HTMLCSS) and Excel's interpretation of the 2 versions of HTML tags -- The "vanilla" HTML 3.2 file and text-align worked with Excel and the HTMLCSS-generated file did not (even though it was HTML 3.2). Very strange -- but it didn't work at all with regular ODS HTML (HTML 4.0 tags) or ODS MSOFFICE2K (MS-HTML tags) -- so I suspect some HTML/Excel strangeness at work.

If you must use HTMLCSS or HTML4, then you might consider contacting Tech Support for further help.

cynthia
NCNyrk
Calcite | Level 5
That did it!

Thanks as always, Cynthia
NCNyrk
Calcite | Level 5
Cynthia,

When using the same approach with Proc Report, I do not seem to be able to force the column width using CELLWIDTH...does that option not work in Proc Report in HTML 3.2 code?

Thanks,
Kryn
Cynthia_sas
Diamond | Level 26
Hi:
Well, it may be Tech Support time...when I do this:
[pre]
title; footnote;
ods html3 file='c:\temp\testjust_ht3x.xls' style=sasweb;

proc report data=sashelp.class nowd;
define name /style(column)={htmlstyle="text-align:right;" cellwidth=2in};
define age / display;
define height /display;
run;
ods html3 close;
[/pre]

I get name right-aligned in a BIGGER column -- is it really 2 inches??? It doesn't look like it to me, but it IS bigger than it is without the CELLWIDTH style override.

So, I'm not sure what's happening.

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1420 views
  • 0 likes
  • 2 in conversation