BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Please, can you help me get to sleep?... I've been at this far too long for something so ostensibly simple.

I would like to have some text in my footnote left justified, and other text right justified. Sounds simple, right? Just precede the text string to be left justified with "just=l" and then precede the text string to be right justified with "just=r" right?

My problem is this: doing so in ODS HTML, I can never seem to get the text following "just=r" to be completely right-aligned. It actually appears somewhat right-of-center, left of the right margin... That's not what I want. I can vary the degree of "error," if you will, by changing the ODS style, changing the point-size of the font, padding a non-justified (default left for whole line) string with spaces or non-printing characters, modifying the template, or reverting back to inserting hard-coded HTML tags like "DIV" or "p" align, etc. But I haven't had complete success.

Here is some sample code to demonstrate:

%let pgmname = TEST;

options nodate nonumber nobyline center papersize=letter orientation=landscape ls=171 ps=55
leftmargin="0.5in" rightmargin="0.5in" topmargin="0.5in" bottommargin="0.5in"
;

ods listing close;
ods html file="%sysfunc(pathname(work))\test.html" style=statdoc;

%let r = Generated on %sysfunc(compbl(%qsysfunc(left(%qsysfunc(date(), downame.)%str(, )%qsysfunc(date(), worddate.)))));

title1 j=c "This is a test";
footnote1 f=sasfont h=6pt j=l "&pgmname..sas" j=r "&r";

data _null_;
file print;
x = ' ';
y = rank(x);
put x= y= ;
run;

ods html close;
ods listing;

/* EOF */

I have spent far too long at this... especially since this is ancillary to the real content of my deliverable. I have scoured support.sas.com and the many excellent publications and posts by the SAS ODS experts such as Cynthia, Chevell, Allison, Eric, et al. I've been debugging SAS code for nearly 15 years, so this simple problem is becoming somewhat embarassing. I would be extremely grateful to anyone who may have a solution.

- Tzvi is me

Note: it appeared that some of my post was cut off initially. Perhaps it was my attempt at including an HTML tag or two. Hopefully removing them does the trick...

Yup. That did it... No embedded HTML in future posts from me.


Message was edited by: Tzvi Message was edited by: Tzvi
8 REPLIES 8
Ksharp
Super User
HI . It is very weird. and also spent me a lot of time.
But I finally have a resolution. It is a little trick.

[pre]
ods listing close;
ods html file="c:\test.html" style=statdoc;

title1 'This is a test';
footnote1 color=blue "test.sas" color=white "aaaaaaaaaaaaaaaaaaaaaa" color=blue "Generate on" ;

proc print data=sashelp.class ;
run;

ods html close;
ods listing;
[/pre]



Ksharp Message was edited by: Ksharp
Tim_SAS
Barite | Level 11
Hmmm...What release of SAS are you using? This worked just fine for me:

[pre]
ods html file="title.html" style=statdoc;
ods listing close;
title j=l "|Left" j=r "Right|";
footnote j=l "|Left" j=r "Right|";
proc print data=sashelp.class(obs=1);
run;
ods listing;
ods html close;
[/pre]
deleted_user
Not applicable
> Hmmm...What release of SAS are you using? This worked
> just fine for me:
>
> [pre]
> ods html file="title.html" style=statdoc;
> ods listing close;
> title j=l "|Left" j=r "Right|";
> footnote j=l "|Left" j=r "Right|";
> proc print data=sashelp.class(obs=1);
> run;
> ods listing;
> ods html close;
> [/pre]

Thanks for the quick replies, Tim and Ksharp.

I'm using SAS v.9.22 on my Windows XP (SP3) laptop now. We also run v.9.22 on AIX 6.1 (TL01) which we connect to via v.9.22 on a Citrix box on a Windows network share. For this test shared in the forum, just my PC SAS (the former).

What I find with ODS HTML is that the "just=" option creates separate newsprint-like columns for each of left, center, and right designations. Text strings specified for each will wrap in their respective columns when they exceed a certain threshold. And yet, for the right-hand column, wrapping occurs before text on the first line reaches the right margin.

Using a narrow table such as SASHELP.CLASS, as both you and KSharp did can hide these characteristics, since the text in the footnote is wider than the table from the PROC PRINT. Try transposing the data and printing, and I think you'll see what I mean:

[pre]
ods listing close;

ods html file="%sysfunc(pathname(work))\test.html" style=statdoc;

%let r = Generated on %sysfunc(compbl(%qsysfunc(left(%qsysfunc(date(), downame.)%str(, )%qsysfunc(date(), worddate.)))));

title1 'This is a test';
/*KSharp: footnote1 color=blue "test.sas" color=white "aaaaaaaaaaaaaaaaaaaaaa" color=blue "Generated" ;*/
/*Tim@SAS:footnote j=l "|Left" j=r "Right|";*/
/*Tzvi.1: footnote1 "&pgmname..sas%qsysfunc(repeat(%sysfunc(byte(160)), 50))&r";
/*Tzvi.2: footnote1 color=blue "test.sas" color=white "%sysfunc(repeat('00'x, 20))" color=blue "&r" ;*/
footnote1 f=sasfont h=6pt "&pgmname..sas%qsysfunc(repeat(%sysfunc(byte(160)), 50))&r";

proc print data=sashelp.class ;
run;

proc transpose data=sashelp.class out=class name=measures;
id name;
var sex age height weight;
run;

proc print data=class label noobs split='^';
label measures='Measures /^Student';
run;

ods html close;
ods listing;

/* EOF */
[/pre]

With wider output the issue becomes more prominent. I thought perhaps using a fixed-width font and a smaller point-size might help. But I think initial HTML table definitions supercede. And padding tricks like the ones KSharp and I tried only seem to help demonstrate the newsprint-like columnar issues I mentioned.

I would think there would have to be a mechanism to probe the table attributes in order to determine what "right" means, and in what context. One difference I noticed, but that I'm not sure matters, is that my first little test used a DATA _NULL_, while subsequent tests have used PROC PRINT. Either way, an HTML table is generated, but I'm pretty sure the results are slightly different due to the ODS template differences. So are we testing in the same context here, Tim? Does it matter?... Isn't the footnote in a separate table (or DIVision?).

Thanks again for the quick response.

- Tzvi is me
Tim_SAS
Barite | Level 11
>
> What I find with ODS HTML is that the "just=" option
> creates separate newsprint-like columns for each of
> left, center, and right designations. Text strings
> specified for each will wrap in their respective
> columns when they exceed a certain threshold. And
> yet, for the right-hand column, wrapping occurs
> before text on the first line reaches the right
> margin.
>

Try changing the width of the browser window. What happens as the browser re-flows the text?

Here's what I see in the HTML. Each title and footnote is rendered as a table that is as wide as the browser window. There is one table with one row for each title/footnote. The row will have is one, two, or three columns depending on how many different pieces of text there are to be justified. Here's a simplified version of the HTML for a title with all 3 pieces of text:

[pre]






Left-justified text Center-justified text Right-justified text

[/pre]

The width properties ensure that, regardless of the relative widths of the columns, the left and right columns will always be 33% of the width of the table and the center column will always 34% of the width. Since the table width is 100% of the browser window the column widths will change as you widen or narrow the browser window. The text-align properties ensure that the text in the left-most column will be left-aligned, the text in the middle column will be center-aligned, and the text in the right column will be right-aligned.

If the text in a column is wider than the column and so must be wrapped to fit, there is nothing in the HTML that indicates where the text should wrap. That's up to the browser. The wrap location changes as I change the browser window width and if I make the window wide enough it doesn't wrap at all. I also wouldn't be surprised to see minor differences between browsers and browser versions.

So if, as you say, "for the right-hand column, wrapping occurs before text on the first line reaches the right margin," that's a function of the browser, not ODS HTML.

Changing the font or the pointsize potentially changes the text width. Changing to a bigger pointsize makes the text wider, more likely to wrap, and more likely to need wrapping sooner closer to the start of the text. However, it's still up to the browser to decide where to wrap the text.
deleted_user
Not applicable
Thanks again, Tim. Problem solved...

Looks like it is actually working as expected, and just as you described... But only in the "right" browser. What I was seeing per my previous posts was from the rendering of the output in the SAS Results Viewer, not in a separate browser. When I finally got around to opening it in a browser (MS IE 6.02), bingo! Guess I was too lazy to open it separately! (doh!)

I saw the same table definitions for the title and footnote in my HTML output as what you mentioned in your simplified version depicting the three data cells ("td") for each of the possible justification positions ("just=") in one row ("tr") in a separate table ("table") for each title/footnote. This helped me a lot. Once I saw that there was no essential differences between my HTML output file and your snippet, I knew my problem must pertain to screen rendering, and so I finally opened it in MS IE.

Needless to say, that was somewhat embarrassing. But it reminded me of a lesson I learned a long time ago. I'm usually a fairly cautious programmer and spend quite a bit of time at work in quality testing code. This was such an elementary lesson, and one which I mentor junior programmers on all the time--always review your output in the target environment, not the developer's environment; make sure you know what your end-users/customers will see.

Thanks for the re-education!

Actually, to further clarify the "problem" (which really isn't) in the SAS Viewer, I was viewing the output in a SAS window that was initially too narrow to display the full table for the transposed SASHELP.CLASS data. The SAS Viewer window had a horizontal scrollbar added between the time I initially printed the SASHELP.CLASS data and when I subsequently printed the transposed version. The SAS Viewer kept the footnote width exactly the same for both printouts, making it too narrow for the latter. Interestingly, scrolling to the right using the horizontal scrollbar had no affect on the positioning of the right-justified footnote text. It was only by expanding the width of the whole SAS window that the text moved properly to the right with the table. The text seems to be "locked" into whatever position you leave the horizontal scrollbar until you change the width of the whole window.

- Tzvi is me
Tim_SAS
Barite | Level 11
Thanks for passing on the good news, Tzvi. Have a good weekend!
deleted_user
Not applicable
Sorry, Tim, I thought I'd be closing this topic...

As far as ODS HTML alone is concerned, the title/justificartion issue is closed. But not necessarily when you save the ouput with an *.XLS extension and open it in Excel. I tried this with both HTML alone and also HTML3 with a "stylesheets" statement on the same PROC PRINT code. In either case, the text to be right-justified appeared in the second column, just to the right of text to be left-justified, in the right-most column. I did not take the extra time to test using tagsets.ExcelXP, in case you might be wondering.

Any thoughts?

- Tzvi is me Message was edited by: Tzvi
Tim_SAS
Barite | Level 11
I don't see this behavior. It may depend on which version of Excel you're using. I'm using Excel 2007.

In any case, HTML is still HTML even when the file has an .XLS extension (see Cynthia's numerous posts on this topic) and all you're doing is testing Excel's ability to import HTML.

I also tried tagsets.excelxp. The result is quite a bit different. At 9.2 using the "stock" version of the tagset, each piece of text gets its own row. Each piece is definitely left-, center-, or right-justified as required.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 2933 views
  • 0 likes
  • 3 in conversation