PRINT [TABLE] ["text string" | stringVariable] {inputVector[formatSpec]}

Prints the contents of the input vectors to the Statistics101 Output Window. All arguments are optional. The keyword table and/or the text string, if any, must appear prior to the first of the inputVector arguments, if any.

If there are no input vectors, then the command prints a blank line:

PRINT    'prints a blank line

If a text string is present, it will be printed on its own line followed by the printout of the input vectors,if any, in a format determined by the presence or absence of the table keyword and the presence or absence of format specifications. The format specifications are described in the help entry on the WRITE command. The text string must be enclosed within quotes:

PRINT "Class average score" average

The above command line prints the following to the Output Window (assuming that the vector average has been defined and has the value shown here):

Class average score
average: 79.0

You get the same result if you break the original PRINT command into two:

PRINT "Class average score" 
PRINT average

If the keyword table is omitted, the input vectors are printed one to a line, in the order they are listed in the command. The name of the vector is printed first, followed by a colon (":"). Then all the elements of the vector are printed on the same line, enclosed in a pair of parentheses. If the vector or variable being printed has only one value, it is printed without the parentheses. Formatting specifications (described in the help entry on the WRITE command) are allowed with this form of the command, but adjacent list elements will be separated by only one space for the format codes F, E, G, and B, no matter what field width is specified. The field width is honored by the C format code.

If the keyword table is present, the input vectors are printed as a table where each input vector is a column of the table. The first vector's contents will be the first column, the second vector's will be the second column, and so on. If the vectors are of different lengths, the columns of the shorter vectors will be filled in with a "-". Formatting specifications are allowed when the table keyword is present. The format specifications are described in the help entry on the WRITE command. Specified Field widths are honored when the keyword table is present.

If there is more than one input vector and you use a format spec for some of the vectors and no format spec for one or more of the vectors, the columns of the vectors without format specs will be formatted with the default spec "%14.6G".

If you use no format specifications (when using the table keyword) the result will be that all the values will be written with the format specification "%14.6G".

Incidentally, it happens that the name of a vector, including its capitalization, is assigned when it is first created. Although Statistics101 does not distinguish names based on capitalization, the capitalization that will be used by PRINT is that assigned when the vector is first created. As you can see in the second and third examples at right, the vectors are originally named with leading caps. The column names therefore have leading caps even though they are referred to using lower case names in the PRINT command.

See also: OUTPUT, READ, WRITE

SAMPLE 5 1,100 A
MEAN A  meanA
STDEV a stdevA
PRINT A  meanA stdevA

The above program produced the following output:

A: (17.0 94.0 39.0 17.0 14.0)
meanA: 36.2
stdevA: 33.83341543503996

This next program shows a simple way to print a table using the table keyword.

BINOMIALPROB 10 0.5 Probabilities
COPY 0,10 Trials
PRINT table trials probabilities

Here's the resulting table:

Trials        Probabilities	
0.0E00        9.76562E-04
1             9.76562E-03
2             4.39453E-02
3             0.117188  
4             0.205078  
5             0.246094  
6             0.205078  
7             0.117188  
8             4.39453E-02
9             9.76562E-03
10            9.76562E-04

This next example shows the same program but with the use of fixed-point formatting specifications.

BINOMIALPROB 10 0.5 Probabilities
COPY 0,10 Trials
PRINT table trials%8.0F probabilities%8.4F

Here's the formatted output:

Trials        Probabilities
0             0.001   	
1             0.0098  	
2             0.0439  	
3             0.1172  	
4             0.2051  	
5             0.2461  	
6             0.2051  	
7             0.1172  	
8             0.0439  	
9             0.0098  	
10            0.001   	

Here's an example showing what happens with the table keyword when the vectors are of differing lengths:

COPY 1,10 longVector
COPY 1,5 shortVector
PRINT table longvector shortVector

With this result:

longVector    	shortVector          	
1             	1             	
2             	2             	
3             	3             	
4             	4             	
5             	5             	
6             	-             	
7             	-             	
8             	-             	
9             	-             	
10            	-  

Here is a example program showing the use of the non-tabular PRINT command without and with format specifications:

NORMAL 10 0 1 vec
PRINT "Without format spec:" vec
PRINT "With format spec:" vec%10.4F

And here is the output of the above program:

Without format spec:

vec: (0.9551819770868651 -1.7431460831750483 0.18169811814749778 -0.27681931135882026 -1.3243225029186239 0.7857185182530638 -0.22848012123130895 1.2965612888346623 -1.0364119934021692 1.0206416167413337)

With format spec:

vec: (0.9552 -1.7431 0.1817 -0.2768 -1.3243 0.7857 -0.2285 1.2966 -1.0364 1.0206)

The PRINT command also works with named constants as this next example demonstrates:

NAME (1 2 3 11 12 13) ace deuce trey jack queen king
COPY ace,trey 4,10 jack,king Suit
SHUFFLE suit ShuffledSuit
PRINT table suit shuffledSuit

Which produced the following output:

Suit          	ShuffledSuit  	
ace           	ace           	
deuce         	6             	
trey          	deuce         	
4             	trey          	
5             	king          	
6             	10            	
7             	8             	
8             	5             	
9             	9             	
10            	jack          	
jack          	4             	
queen         	7             	
king          	queen