The SAS Output Delivery System and reporting techniques

Create sub-reports (reports side by side)

Reply
Frequent Contributor
Posts: 83

Create sub-reports (reports side by side)

I would like to take two proc print statements and have the final result print side by side instead one on top and the other below it. Is this possible?

Here are the two proc print statements:

proc print data=total noobs;
label earnings='Earnings'
rank='Rank';
sum earnings;
title1 'Best 5 Years';
run;

proc print data=years noobs;
label retire_age= 'Retire Age'
yrs_service= 'Yrs Service';
title1 'Retire Age & Yrs of Service';
run;

I am running this as an ODS HTML so they are already on one page together. But I will have multiple statements and I would like to save paper and put these little reports side by side if at all possible. Any help with this would be appreciated.
SAS Super FREQ
Posts: 8,868

Re: Create sub-reports (reports side by side)

Hi:
You can use the HTMLPANEL tagset template to create an HTML file where the outputs are arranged in a side-by-side fashion. The documentation and examples for using the HTMLPANEL tagset template are here:
http://support.sas.com/rnd/base/ods/odsmarkup/htmlpanel.html

Just remember that if you want to print the HTML file, that the print interface (for saving paper) is between the browser and the printer. SAS has little to no control over how the output prints -- all the printing is controlled by the browser.

An output that fits on one HTML "page" may or may not equate to one physical printed "page". An HTML file can be as wide or as long as it needs to be and would still be considered 1 HTML "page". But when you go to print that HTML page using the browser controls, the 1 HTML "page" may span multiple physical printed pages.

cynthia
Frequent Contributor
Posts: 83

Re: Create sub-reports (reports side by side)

Posted in reply to Cynthia_sas
Thank you Cynthia. That has helped tremendously. I was hoping you could help with one last thing. When I create the panels when I get to the 4th group of panels that I want to create, this happens to be the group when I print that gets cut in half. (The top half is on the first page and the bottom half is on the second page). What is the easiest way to prevent this? Do I insert a page break before this panel of code? Here is the code.

/* start fourth, semi-automatic panel */
ods tagsets.htmlpanel event = panel(start);

title 'Percent Formula Benefit';
proc print data=SASUSER.APPEND_TABLE_0049 noobs;
sum equiv amount;
run;

title 'Preliminary Benefit';
proc print data=SASUSER.QUERY1456 noobs;
run;

ods tagsets.htmlpanel event = panel(finish);
SAS Super FREQ
Posts: 8,868

Re: Create sub-reports (reports side by side)

Hi:
A tangent: In the very old days, when HTML was first introduced, the web was supposed to lead us to the paperless office. Remember the paperless office? It was a lovely vision. And yet, what's the first thing that most folks do when they see something on a web page that they want to keep/remember?? Do they make a favorite for it?? Do they jot a little note with the relevant number of a piece of recycled paper?? Noooooo -- they go to FILE --> PRINT. Now, back to your question. Here's what I tell my students when they ask about printing control over HTML files:
There are no page breaks in the paperless office. Printing control over HTML pages is "iffy".

Initially, back in the days when HTML was being "invented", the HTML folks over at the W3C did not put ANY kind of printing controls or page breaking controls into the HTML spec. This has to do with the HTML folks at the W3C hoping that HTML was leading to the paperless office and saving paper.

When the HTML folks at the W3C came to the sinking realization that folks were printing HTML pages and clamoring for more control over printing, the place where any kind of controls were introduced (again, nothing to do with SAS) were in the CSS specification (I think it was actually CSS 2.0 standard). If you have a BROWSER that is CSS compliant and honors the page-break style property, then, when your BROWSER prints the HTML page that contains the CSS style property, you may get the CSS page-break control honored. This has nothing to do with SAS. When SAS creates HTML files, we (SAS) can't invent a page-break control. We can only use what's defined in either the CSS spec or the HTML specification. And, even if we -USE- what's defined in either specification -- SAS has no control over what browser you use to open and print the HTML file and has no control HOW the browser might or might not use the CSS style property.

Usually, if printing is important, I recommend the creation of PDF files, where
1) the file is generally uneditable unless someone has an Adobe produce
2) printing happens as the file was originally designed.

A lot of times, web designers will have a button on an HTML page for the "printable" version of the same page -- this generally turns out to be a PDF version of the page information.

If you reread my original posting to your question, I had a warning there:

Just remember that if you want to print the HTML file, that the print interface (for saving paper) is between the browser and the printer. SAS has little to no control over how the output prints -- all the printing is controlled by the browser.


Now, more about the CSS property that ODS does insert into a regular ODS HTML file. In a regular style template for ODS HTML, ODS uses a <HR> (horizontal rule) between tables to indicate a "page break" Attached to this <HR> is a &LT;P&GT; tag which contains the ONLY page-break control that there is, page-break-after: always; which is the CSS style property that is described here (in the specification) on the W3C site: http://www.w3.org/TR/CSS21/page.html#page-break-props

The relevant section from the style template STYLES.DEFAULT is shown below.
[pre]
class html
"Common HTML text used in the default style" /
'expandAll' = "<span onclick=""expandCollapse()"">"
'posthtml flyover line' = "</span><hr size=""3"">"
'prehtml flyover line' = "<span><hr size=""3"">"
'prehtml flyover bullet' = %nrstr("<span><b>&#183;</b>")
'posthtml flyover' = "</span>"
'prehtml flyover' = "<span>"
'break' = "<br>"
'Line' = "<hr size=""3"">"
'PageBreakLine' =
"<p style=""page-break-after: always;""><br></p><hr size=""3"">"

'fake bullet' = %nrstr("<b>&#183;</b>");[/pre]

I have never tried to change or insert a page break into an HTML file because
1) you have to know, for sure, that your users' browsers support this type of CSS
2) since each user can change print settings using the browser File --> Print controls, there's no guarantee that they'll print the HTML page in the orientation that you wanted/planned.
3) If the report user cuts and pastes from the HTML page into a Word doc (for example) and then tries to print, Word (or any other app) may or may not respect the CSS style property.

When I said that SAS had "little to no control" over printing, what I meant was that SAS and ODS put the CSS page-break-after: always; style property into the HTML file. Once the file is opened in the browser, SAS is out of the picture.

I don't know how or where or even if the HTMLPANEL tagset is inserting the page-break-after:always CSS property or how to control the insertion of the CSS information when using the HTMLPANEL tagset template. Once HTMLPANEL is in the picture, you are using panel start/finish options to arrange the tables in panels. I suspect, but do not know for sure, that the HTMLPANEL tagset might not be using the "PageBreakLine" style element, as defined in STYLES.DEFAULT. This is probably a question for Tech Support.

To open a track with Tech Support, go to http://support.sas.com/ and in the left-hand navigation pane, click on the link entitled "Submit a Problem". Alternately, you can go directly to the Tech Support Problem Form here: http://support.sas.com/ctx/supportform/createForm

cynthia
Frequent Contributor
Posts: 83

Re: Create sub-reports (reports side by side)

Posted in reply to Cynthia_sas
Hi Cynthia,
Thanks for the clear explanation on that. My hopeful outcome for the report is to be a stored process. However, I created the stored process and the side-by-side formatting I created with the paneling code disappeared. Can you not do this with a stored process? Or am I doing something incorrectly? Below is some code taken from the stored process. The final results inserts page breaks in between each proc print and puts each report on top of each other.

I also would utimately like to put this in the Web Portal and I can have the user select under the execution options the PDF file. So hopefully this will clear up the page break issue if I figure out why all the formatting goes away in the stored process. Any help with this would be appreciated. I created the stored process using the wizard in Enterprise Guide 4.0

%LET _CLIENTTASKLABEL=;
%LET _EGTASKLABEL=;
%LET _CLIENTPROJECTNAME=;

%LET _CLIENTTASKLABEL=%NRBQUOTE(All Other Charts);
%LET _EGTASKLABEL=%NRBQUOTE(All Other Charts);
%LET _CLIENTPROJECTNAME=%NRBQUOTE(D:\SASDM\TSSUser\tssl.adams\egpuser\Oracle\Pension_Plan.egp);
%LET _SASPROGRAMFILE=;

%gaccessible;
goptions dev=gif xpixels=480 ypixels=320;

ods tagsets.htmlpanel nogtitle file="printpanel2.html"
options(panelcolumns='3'
panelborder='2'
embedded_titles='yes'
bylabels='no');

/* start the panelling */

ods tagsets.htmlpanel event = panel(start);

title 'Best 5 Years';
proc print data=WORK.Query_for_QUERY1897 noobs;
run;

title 'Best 5 Yrs Monthly Average';
proc print data=WORK.Query_for_Query_for_QUERY1897 noobs;
run;

title 'Retire Age & Yrs of Service';
proc print data=WORK.QUERY_FOR_PENSION_MSTR_0006 noobs;
run;


/* Stop the current Panel */
ods tagsets.htmlpanel event = panel(finish);
SAS Super FREQ
Posts: 8,868

Re: Create sub-reports (reports side by side)

Hi:
Knowing that you ultimately want a stored process does change the answer a bit -- it makes the answer more complicated -- because destination results that work in Base SAS might work differently in different client applications. Printing in the BI Platform client apps is not handled via a browser -- so now, you have OTHER issues beyond the printing issue. And, depending on the client application you plan/want to use to open the SP -- I think the client app issue overrides the printing issue. Because now, the browser is pretty much out of the picture and now you're dealing with printing from a client app -- IF (and this is a HUGE, GYNORMOUS qualifying IF) IF your client app can/will receive and render HTMLPANEL results and IF your client app can/will honor the CSS print properties (probably not, in my experience).

When you create a stored process from an existing SAS program, you have to know what type of stored process results your client application can "receive" and what the default stored process type is. So, for example these are the client apps that can handle stored processes shown with their default type of output for stored process results and the other types of ODS output they can "accept" or "receive" or "render":
[pre]
Client App Stored Process Default Can Accept Other Types
EG SASReport XML HTML* , RTF, PDF
Word SASReport XML RTF, HTML*
Excel SASReport XML CSV, HTML*
PPT SASReport XML SASReport XML
WRS SASReport XML SASReport XML
Portal HTML almost any ODS destination,
including SASReport XML
[/pre]

* Note most -simple- HTML-based tagset destinations, like HTML3, MSOFFICE2K, CHTML, PHTML can be used with stored processes. Whether the HTMLPANEL output will work depends on the client application. I suspect, but have not tested, that HTMLPANEL will work with SAS EG; might work with Word; will probably NOT work with Excel; and definitely will NOT work with PPT or WRS (Web Report Studio).

So, that's one issue. The other issue is that when you create a stored process in EG, EG will hide the %STPBEGIN/%STPEND stored process macro invocations. Usually, if you were writing a stored process -outside- of EG, you'd change the destination this way -- for any client application that ran this stored process, the client app would receive MSOFFICE2K form of HTML. Now, if I try to run this stored process in WRS or PPT, those client apps do NOT handle HTML results, they would (behind the scenes) essentially ignore my override for _ODSDEST reserved macro parameter:
[pre]
*ProcessBody;
%let _odsdest=msoffice2k;
%stpbegin;
...your code without any ods "beginning statements" or FILE= option ...

%stpend;
[/pre]

Note that with this type of invocation, you do not specify a FILE= option -- that's because stored processes do not use a physical file name for sending stored process results. Stored process results come from either the stored process server or the workspace server over a special "pipeline" that has the name "_webout" -- you can't change that name if you're running a stored process.

Things get a little trickier with HTMLPANEL, because you have suboptions to specify and intermediate ODS TAGSETS.HTMLPANEL statements to supply. I believe that it is -doable- but really, really, really depends on the client applications you intend to use for receiving these stored process results. Also, depending on the version of SAS installed on your server, you may or may not have the HTMLPANEL tagset or the most current copy of the tagset available to be used.

For side by side layout of SASReport XML results, I believe you can use the Document Window in EG to design and layout the tables in a side-by-side fashion. I do -not- know whether you can surface a report like this via a stored process -- that would be a question for Tech Support or for the EG folks.

So, if you were hoping to get the side by side layout in WRS or PPT, you're not going to be able to do that at all using the HTMLPANEL tagset template. If all you want to do is create a stored process whose results will come back to EG, then you might be able to manually convert your code to a stored process that will work. If you want to create a stored process that will run in Word or Excel, then you should create your HTMLPANEL output -- not as a stored process -- and then go to Word and go to Excel and see what happens when you open the HTMLPANEL output with either of those applications. However the output looks without a stored process being involved is how the application handles the HTML that is being written. Your turning the code into a stored process won't change this behavior.

For more information about creating a stored process and how to supply overrides to the reserved macro parameters, refer to these papers (shows to the 9.1.3 Platform and 9.1.3 SAS, however, the general behavior and concepts are still correct):
http://www2.sas.com/proceedings/forum2008/024-2008.pdf
http://www2.sas.com/proceedings/forum2007/021-2007.pdf
http://www2.sas.com/proceedings/sugi30/135-30.pdf
http://www.nesug.org/Proceedings/nesug09/hw/hw06.pdf (EG 4.2)

For help specifically in turning your HTMPANEL example into a stored process -- assuming that you can live with the result type limitations (no WRS, no PPT, probably no Excel), then your best resource would be to open a track with Tech Support for more direct help.

cynthia
Frequent Contributor
Posts: 83

Re: Create sub-reports (reports side by side)

Posted in reply to Cynthia_sas
Thanks so much for your help Cynthia. I will probably contact Tech support for more help on this.

Thanks Again!
Ask a Question
Discussion stats
  • 6 replies
  • 1265 views
  • 1 like
  • 2 in conversation