SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 37768: Determine the value of the PROC REPORT _BREAK_ automatic variable

DetailsOutputAboutRate It
This sample illustrates how to determine the value of the PROC REPORT _BREAK_ automatic variable.

PROC REPORT automatically creates a variable called _BREAK_. This variable contains:

  • a blank if the current line is not part of a break
  • the value of the break variable if the current line is part of a break
  • the value of RBREAK if the current line is from the RBREAK statement

In the current code, add a new variable. In the example below, the new variable is named FLAG. Define FLAG as a COMPUTED variable with a format that is at least 8 characters long. The length does need to be long enough to accommodate the length of the break variable name.

Add a COMPUTE block for the new variable. Assign the value of the _BREAK_ to the new COMPUTED variable and run the code. The COMPUTED variable will show the _BREAK_ value that created the line of output, _RBREAK_ for the rbreak row, and a blank for a detail row of output. The sample code below shows this technique.

PROC REPORT NOWD DATA=sashelp.class; COL age sex name weight flag; DEFINE age / ORDER; DEFINE sex / ORDER; DEFINE flag / COMPUTED format=$25.; BREAK AFTER age / SUMMARIZE; BREAK AFTER sex / SUMMARIZE; RBREAK AFTER / SUMMARIZE; COMPUTE flag / CHAR; flag=_BREAK_; ENDCOMP; RUN;

As an alternative to the technique above, an output data set can be created to show the _BREAK_ value. Add the OUT= option with a valid DATA set name on the PROC REPORT statement. Use a PROC REPORT or a PROC PRINT to print out the new DATA set.

PROC REPORT NOWD DATA=sashelp.class OUT=mybreak; COL age sex name weight ; DEFINE age / ORDER; DEFINE sex / ORDER; BREAK AFTER age / SUMMARIZE; BREAK AFTER sex / SUMMARIZE; RBREAK AFTER / SUMMARIZE; RUN; PROC PRINT DATA=mybreak; RUN;



These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.