Data editing > Writing out data > Writing to a report file > Examples of report statements
 
Examples of report statements
Example 1
reportn summary 20t,$Bought Brand A$,1x,brda:3,1x,$times$
prints a report of the form:
Bought Brand A   5 times
Bought Brand A   9 times
Bought Brand A  13 times
in a file called summary. Printing starts in position (column) 20 because you started the parameter list with the keyword 20t. The variable brda is an integer variable whose value is to be right-justified in a field three columns wide. There are inserted spaces between the texts and the value of brda.
Example 2
The statements:
/* only print title if this is the first record in the data file
if (.not. rchk)
+reportn yogurt 30t,$Serial Numbers for Yogurt Buyers$
if (c119'1') reportn yogurt c(1,4)
       .
rchk = 1
produce a report showing the serial numbers of all respondents who buy yogurt.
Example 3
This example shows the difference between printing a field of columns all in one go and printing them one at a time. If the data is:
+----4----+
18 036
& /
7
the statement:
reportn test $c(37,43) is $,c(37,43)
produces:
c(37,43) is 106
However, if you deal with each column separately:
reportn test $c(37,43) is $,c37,c38,c39,c40,c41,c42,c43
produces:
c(37,43) is 1* 0*6
Note You cannot write information to the standard print file (usually called out2) using report. To do this use the qfprnt function: see Writing out data in a user-defined format.
See also
Writing to a report file