Desktop productivity for business analysts and programmers

Break and Skip statement

Reply
N/A
Posts: 0

Break and Skip statement

I use to work on regular SAS but we decided to move to EG. Most of the break and skip statements are not breaking/skipping at the right positions. Below is the sample code - How to modify the below break and skip statement so that they work right in EG?

proc report data=all headline spacing=1 split='|' nowindows missing;
column page ord stat visit ("_Cohort_" treat1-treat&numtrt) total;

define page / order order = internal noprint;
define ord / order order = internal noprint;
define stat / display ' ' width=22;
define visit / display 'Visit' width=8 flow id;

%do i=1 %to &numtrt;
define treat&i / width=18 center "&&trttxt&i~n(N=&&ntrt&i)";
%end;
define total / width=18 center "Total~nN=%sysfunc(compress(&BigN)))";

break after page / page;
break after ord / skip;
run;
Respected Advisor
Posts: 3,823

Re: Break and Skip statement

Hi

EG is only a SAS client.

The code is executed on the SAS Workspace server (and this server can even be your "regular SAS" installed locally on your PC - it then would show up in EG as server "local").

Did the code you've posted already run in your "real SAS" environment - or is this a new/modified version?

And did the produced output go the the same output destination (i.e. listing)?

If not: You might just have to tweak your code and chosen output destination.

Cheers
Patrick
N/A
Posts: 0

Re: Break and Skip statement

Patrick: Output destination is not same. Previously used to be .lst and now it is .rtf via ods statement as below -

ods rtf file = "&rtfdir.\&pgm..rtf" style = CRP;

The code is same as previous SAS version except now in EG we are redirecting to rtf as I said above.
SAS Super FREQ
Posts: 8,716

Re: Break and Skip statement

Hi:
BREAK, SKIP, HEADLINE, HEADSKIP, DOL, DUL, OL, UL, WIDTH, FLOW, PANEL and BOX are some of the "LISTING" only options of PROC REPORT. This means that options, like SKIP that worked in LISTING are basically ignored by ODS destinations, such as RTF, PDF or HTML.

If you had a program with:
[pre]
BREAK AFTER BRKVAR/ SUMMARIZE SKIP;
[/pre]

for example, you would need to move to a COMPUTE block syntax to accomplish the equivalent of a skipped line. And, in your COMPUTE block, you would achieve a skipped line with a LINE statement:
[pre]
BREAK AFTER BRKVAR/ SUMMARIZE;
COMPUTE AFTER BRKVAR;
LINE " ";
ENDCOMP;
[/pre]

There have been many previous forum postings on the fact that there are some LISTING only options that do not work with the other ODS destinations when you use PROC REPORT (and PROC TABULATE, for that matter).

For more information about the fact that these LISTING-only options do not work with other ODS destinations, see this Tech Support note:
http://support.sas.com/kb/2/549.html
and this "workaround" example code for how to simulate some of the options (mostly using CSS style properties):
http://support.sas.com/rnd/base/ods/templateFAQ/report1.html (do note that the CSS style property method of simulating PROC REPORT options will generally only work for ODS HTML or HTML based ODS output -- many of the CSS methods will NOT work for RTF and PDF.)

cynthia
N/A
Posts: 0

Re: Break and Skip statement

Thanks Cynthia. What is the equivalent code for ODS PAGE break -

Break after breakvar / PAGE;
SAS Super FREQ
Posts: 8,716

Re: Break and Skip statement

Hi:
PAGE is not one of the options that are LISTING only. PAGE should work as designed for ODS RTF and ODS PDF. Since ODS HTML is not a 'paged' destination (there are no pagebreaks in a browser) -- the only destination where PAGE would not work would be ODS HTML and probably ODS CSV, etc.

The code below worked for me to create 3 pages of output in RTF and PDF output files. Of course, in the HTML file, although there weren't page breaks, there was a horizontal rule shown in the SASWEB style that indicated where the "logical" page breaks were. Some styles do not use the horizontal rule as a logical page break indicator -- but SASWEB does -- so you should see a horizontal rule in the HTML file. But you said you were interested in RTF and if you try my code, you should see 3 pages of output in the RTF file.

You will not be able to cut and paste directly from the forum posting into SAS or your EG code node, however, The forum "preformatting" for line feeds and carriage returns is sometimes ignored by SAS or the EG code window. So you'll have to cut and paste from the forum posting into Word and then cut and paste the code a second time from Word into the EG code node window.

The ODS _ALL_ CLOSE; statement at the top of the program turns off the AUTOMATIC generation of output that EG turns on by default. So if you have a default location where EG normally puts your output, do note that these programs all create output in the C:\temp directory.

cynthia
[pre]
ods _all_ close;
options nodate number pageno=1;

ods html file='c:\temp\trypage.html' style=sasweb;
ods rtf file='c:\temp\trypage.rtf';
ods pdf file='c:\temp\trypage.pdf';

proc report data=sashelp.shoes nowd;
where region in ('Africa', 'Asia', 'Canada');
column region product sales inventory returns;
define region / group;
define product / group;
define sales / sum;
define inventory / sum;
define returns / sum;
break after region / page summarize;
run;
ods _all_ close;
[/pre]
N/A
Posts: 0

Re: Break and Skip statement

My problem 'may' be not with page break -

As in my first post - I have 16 columns. The ODS RTF was able to output as below.
Both sections are appearing on the same page. However, I want the data from Col9 thru 16 to appear in next page. How can this be achieved?



-------------------------------------------------------------------------------------------------
Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8
------------------------------------------------------------------------------------------------

-- DATA Area --


------------------------------------------------------------------------------------------------
==== I WANT A PAGE BREAK HERE ===
-------------------------------------------------------------------------------------------------
Col9 Col10 Col11 Col12 Col13 Col14 Col15 Col16
------------------------------------------------------------------------------------------------

-- DATA Area --


------------------------------------------------------------------------------------------------
SAS Super FREQ
Posts: 8,716

Re: Break and Skip statement

Hi:
I didn't focus much on your PROC REPORT code because it looked like you didn't post the whole macro program that you were using. And you initially asked about the BREAK and SKIP not working as you expected. Using the PAGE option on the BREAK statement does work as advertised.

I believe your issue is not with the PAGE option. The LISTING destination works one way as far as dealing with output that's too wide to fit in the LINESIZE. The RTF, PDF and HTML destinations work another way as far as dealing with output that's wide.

For one thing, ODS HTML output can be as wide as it needs to be -- since the browser can scroll (almost) infinitely to the right and the left. ODS RTF and ODS PDF output, on the other hand, are bound by physical page dimensions and paper sizes and margins and font sizes. So a report with a LOT of columns will display one way in LISTING (dependent on the LINESIZE, margin, and orientation options) and RTF and PDF will display another way (depending on the ODS style being used, the font sizes, the paper sizes, the system margin settings, the orientation settings, etc). ODS HTML will display an entirely different way.

The way that RTF and PDF will "break" wide tables is not the same as the way that the LISTING destination will "break" wide tables. RTF and PDF decide how many columns can fit in the width of the page, given the factors that I listed above and then will print ALL the rows for those columns before displaying ALL the rows for the rest of the columns. This is different behavior than what you would have observed in the LISTING destination.

One of the first postings I made to the forum was on how to deal with very wide tables for the RTF and PDF destinations by manipulating the font size, cellpadding, margins and orientation options.
http://support.sas.com/forums/thread.jspa?messageID=414ƞ

You will not be able to get one page of columns 1-8 and the next page showing columns 9-16 from PROC REPORT by default. What you describe is the type of paging behavior that you would only see in the LISTING destination -- not RTF, PDF or HTML behavior. You may have to rethink your approach for this report.

Since you were using ODS ESCAPECHAR control characters, I assumed that you were no longer interested in LISTING output -- therefore, you might want to remove the SPACING, FLOW, WIDTH, HEADLINE and other LISTING only options from your code, as they are going to be ignored anyway.

Of course, one thing you could always do is continue to produce LISTING output, and capture the LISTING output in an ASCII text file. You could then open the ASCII text file directly with Microsoft Word and manually manipulate the output in Word to have the margins, orientation, etc that you desire. Or, you might find it easier to work to make the wide output fit into an ODS RTF output file so that all 16 columns fit on one page -- possibly by using the techniques shown in my "very wide table" forum posting.

cynthia
Ask a Question
Discussion stats
  • 7 replies
  • 1291 views
  • 0 likes
  • 3 in conversation