#set TITLE = "proc print"
#include top

.SH DESCRIPTION
\fBproc print\fR may be used to print messages and debugging info.
It can print the contents of variables and/or
data fields to a file or to standard error.
It is mainly useful for displaying or exporting information
pertaining to outlier cases and for debugging a script.
.LP
Unless the \fCoutfile\fR attribute is specified, information is
printed to the file/stream controlled by the \fB-diagfile\fR
command line option.

.SH FEATURES
Cases may be selected using a conditional expression,
for purposes such as identifying outliers.

.SH VARIABLES THAT ARE SET
\fBNSELECTED\fR is set to the number of records selected.
Thus proc print may be used to count number of records meeting a certain criteria.

.SH PREREQUISITES
None.

.SH ATTRIBUTES
.LP
\fBlabel\fR 
.ig >>
<a href="attributetypes.html#text">
.>>
\fI text \fR
.ig >>
</a>
.>>
.IP
Arbitrary text that will be printed once.  May include
@variable references using one at-sign (@).  Typically
used to examine contents of variables or to print a header
for the cases listed by the \fCselect\fR and \fCprint\fR attributes.

.LP
\fBselect\fR 
.ig >>
<a href="condex.html">
.>>
\fI conditional-expression \fR
.ig >>
</a>
.>>
.IP
\fIconditional-expression\fR is a conditional expression which
is applied to each data record (row).
If specified and if the expression evaluates to true, 
the \fCprint\fR template is printed,
otherwise it is not.

.LP
\fBprint\fR 
.ig >>
<a href="attributetypes.html#text">
.>>
\fI text \fR
.ig >>
</a>
.>>
.IP
A template which may include variable and data field references.
This template will be printed once for every data record
that passes the selection condition.
Data fields are referenced by preceding with two at-signs (@@@@).
See example below.

.LP
\fBoutfile\fR \fIfilename\fR
.IP
If specified, the results of proc print will be written to this file.
If unspecified, results are written to the diagnostic stream (controllable
using -diagfile on command line).  New in version 1.40.

.LP
\fBoutmode\fR  \fCw\fR | \fCa\fR
.IP
Controls the file write mode for \fCoutfile\fR.  Default is \fCw\fR.
w = write (create new file / erase
any current contents); a = append (append to any existing contents; if none then
create new file).  See also fopen(2).  New in version 1.40.


.SH EXAMPLE
Example:
.nf
.ft C
\0#declare TODAY
\0#set TODAY = $todaysdate()
\0#proc print
\0label: Outliers (run on @@TODAY)
\0select: @@@@3 > 300
\0print: @@@@1 @@@@2 had a score of @@@@3

#include bottom
