Using the ODS REGION statement to place items on a page

IanBD
IanBD
Altair Employee
edited September 2022 in Altair RapidMiner

The Output Delivery System (ODS) functionality in SAS language programs is used to create formatted output in different file types such as PDF or RTF. In ODS you can use the ODS REGION statement to place items such as text or graphics on a page in destination output such as a PDF file or HTML page.

ODS REGION statements define areas or regions for a page layout specified using the ODS LAYOUT statement. ODS LAYOUT specifies that elements will be positioned within the area defined by the statement; ODS REGION statements then define within that layout regions in which elements can be placed. ODS LAYOUT can be used to define a layout for:

  • A PDF file. Use the statement ODS LAYOUT ABSOLUTE, which enables you to place regions anywhere on a page.
  • An HTML file. Use the statement ODS LAYOUT GRIDDED, which enables you to place regions in columns and rows, similar to an HTML table.

For information on ODS LAYOUT, see the Altair SLC Reference for Language Elements, the forum post about the ODS LAYOUT statement, or the blog posts that describe how to layout a page.

The ODS REGION statement has the format:

ODS REGION options

where options define the position and size of the region.

For a gridded layout, the ODS REGION specifies the position of rows or columns. The width of columns and height of rows is specified by the ODS LAYOUT GRIDDED statement.

For example:

ODS HTML FILE="c:\temp\text.html";
ODS LAYOUT GRIDDED COLUMNS=2 COLUMN_WIDTHS=(50px 200px) ;

ODS REGION COLUMN = 1;
ODS TEXT='Text in column 1, row 1';

ODS REGION COLUMN = 2 ;
ODS TEXT='Text in column 2, row 1';

ODS REGION COLUMN = 1;
ODS TEXT='Text in column 1, row 2';

ODS REGION COLUMN = 2 ;
ODS TEXT='Text in column 2, row 2';

ODS LAYOUT END;
ODS HTML CLOSE;

This writes the specified text to the file text.html; the file can then be displayed in a web browser. The page contains two columns, 50px and 200px in width. The page looks like this:

image

The following code writes text to a PDF file:

ODS PDF FILE="c:\temp\text.pdf";
ODS LAYOUT ABSOLUTE;

ODS REGION HEIGHT=50px WIDTH=100px x=50px y=100px;
ODS TEXT='Text in block1';

ODS REGION HEIGHT=50px WIDTH=100px x=150px y=100px;
ODS TEXT='Text in block2';

ODS LAYOUT END;
ODS PDF CLOSE;

This writes two blocks side by side on a page in the specified PDF file. The page looks like this:

image

Note that on both the HTML and PDF page a title has been automatically generated. This title is the default title for pages. It can be omitted or changed using the TITLE global statement.