Published on :
Utility CREATION_INTERNE

Example of writing with automatic page variables

This code is also available in: Deutsch Español Français
This SAS© code illustrates how to generate a simple report using a DATA step and the FILE statement. It configures the 'print' output file with page and line size parameters (ps=50, ls=80). A DO loop is used to write 100 lines of text. Each line includes information about the page number (PAGNO), the current line number (LIN), and the number of lines remaining on the page (LINLEFT), all automatically derived by SAS©.
Data Analysis

Type : CREATION_INTERNE


No external data is used. The script generates output text for demonstration purposes, using automatic variables from the SAS system.

1 Code Block
DATA STEP
Explanation :
This DATA _NULL_ block does not create a SAS dataset but is used to direct output to the 'print' file. The FILE statement with options ll, line, page, ps, and ls activates and configures the automatic pagination and line variables. The DO loop executes the PUT statement 100 times, which writes a formatted text line, including the values of the automatic variables for page, line, and remaining lines.
Copied!
1DATA _null_;
2 file PRINT ll=linleft line=lin page=pagno ps=50 ls=80;
3 DO x=1 to 100;
4 put 'Page ' pagno 'line number ' lin '- There are ' linleft 'lines left on this page';
5 END;
6RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.