Ploticus > Scripts >
proc print

proc print is a utility proc that doesn't draw anything. Instead, it has the following uses:

    Print contents of script variables (but see also #write/#endwrite)
    Print contents of data fields from data rows meeting certain select criteria (for example, outliers)
    Count number of data rows meeting a certain select criteria (sets NSELECTED)
    Find the data row where a certain item resides (sets FOUNDROW). This row number can then be fed to the $dataitem() function to access other data from the same row.

Result can be written to a file if outfile is specified; otherwise the result appears on the diagnostic stream (controlled by the pl -diagfile command line option). Because proc print turns out to have some distinct usefulness, it is no longer deprecated as of 2.41


label     text

    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 select and print attributes.

select     select expression

    Selects data records to print, using the print template.

print     text

    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.
    This attribute may be left undefined if you are only using proc print to compute NSELECTED or FOUNDROW.

outfile     filename

    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).

outmode     w | a

    Controls the file write mode for outfile. Default is w. 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).

Variables that are set by proc print

Note, these variables are available to the ploticus script after the proc completes execution. We recommend that you use #endproc to delineate the end of proc print. Also, you don't need to print anything if you're just getting these values.

NSELECTED is set to the number of records selected. This may be used, for example, to count number of records meeting a certain criteria (as given in the select statement).

FOUNDROW is set to the row number (first = 1) of the first data row to successfully match the select statement. 0 when no matches are found. This may be used (along with the select statement) to find the data row where a certain item resides. (new in 2.41)


#proc print
label: Outliers:
select: @@3 > 300
print: @@1 @@2 had a score of @@3

#proc print
label: @NSELECTED rows met the above criteria.


Ploticus 2.42 ... May 2013 Terms of use /