Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Language Reference

J Function

creates a matrix of identical values

J( nrow<, ncol<, value>>)

The inputs to the J function are as follows:
nrow
is a numeric matrix or literal giving the number of rows.

ncol
is a numeric matrix or literal giving the number of columns.

value
is a numeric or character matrix or literal for filling the rows and columns of the matrix.
The J function creates a matrix with nrow rows and ncol columns with all elements equal to value. If ncol is not specified, it defaults to nrow. If value is not specified, it defaults to 1. The REPEAT and SHAPE functions can also perform this operation, and they are more general.

Examples of the J function are shown below:

   b=j(3);

                B             3 rows      3 cols    (numeric)

                                1         1         1
                                1         1         1
                                1         1         1


   r=j(5,2,'xyz');

           R          5 rows      2 cols    (character, size 3)

                                xyz xyz
                                xyz xyz
                                xyz xyz
                                xyz xyz
                                xyz xyz

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.