Sample 37768: Determine the value of the PROC REPORT _BREAK_ automatic variable
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.
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.
Output created by Flag variable
S
e
Age x Name Weight flag
11 F Joyce 50.5
11 F 50.5 Sex
M Thomas 85
11 M 85 Sex
11 135.5 Age
12 F Jane 84.5
Louise 77
12 F 161.5 Sex
M James 83
John 99.5
Robert 128
12 M 310.5 Sex
12 472 Age
13 F Alice 84
Barbara 98
13 F 182 Sex
M Jeffrey 84
13 M 84 Sex
13 266 Age
14 F Carol 102.5
Judy 90
14 F 192.5 Sex
M Alfred 112.5
Henry 102.5
14 M 215 Sex
14 407.5 Age
15 F Janet 112.5
Mary 112
15 F 224.5 Sex
M Ronald 133
William 112
15 M 245 Sex
15 469.5 Age
16 M Philip 150
16 M 150 Sex
16 150 Age
1900.5 _RBREAK_
Output created by OUT= data set
Obs Age Sex Name Weight _BREAK_
1 11 F Joyce 50.5
2 11 F 50.5 Sex
3 11 M Thomas 85.0
4 11 M 85.0 Sex
5 11 135.5 Age
6 12 F Jane 84.5
7 12 F Louise 77.0
8 12 F 161.5 Sex
9 12 M James 83.0
10 12 M John 99.5
11 12 M Robert 128.0
12 12 M 310.5 Sex
13 12 472.0 Age
14 13 F Alice 84.0
15 13 F Barbara 98.0
16 13 F 182.0 Sex
17 13 M Jeffrey 84.0
18 13 M 84.0 Sex
19 13 266.0 Age
20 14 F Carol 102.5
21 14 F Judy 90.0
22 14 F 192.5 Sex
23 14 M Alfred 112.5
24 14 M Henry 102.5
25 14 M 215.0 Sex
26 14 407.5 Age
27 15 F Janet 112.5
28 15 F Mary 112.0
29 15 F 224.5 Sex
30 15 M Ronald 133.0
31 15 M William 112.0
32 15 M 245.0 Sex
33 15 469.5 Age
34 16 M Philip 150.0
35 16 M 150.0 Sex
36 16 150.0 Age
37 . 1900.5 _RBREAK_
In a COMPUTE block, the value of the _BREAK_ automatic variable can be evaluated to determine if the current line contains detail or break level data. For customizing output, knowing the correct value of the _BREAK_ is crucial.
Date Modified: | 2019-09-23 13:42:41 |
Date Created: | 2009-11-09 15:10:14 |
Operating System and Release Information
SAS System | Base SAS | z/OS | | |
OpenVMS VAX | | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft® Windows® for x64 | | |
OS/2 | | |
Microsoft Windows 7 | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows XP Professional | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
ABI+ for Intel Architecture | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |