Chapter Contents |
Previous |
Next |
Language Reference |
The CSHAPE function works by looking at the source matrix as if the characters of the source elements had been concatenated in row-major order. The source characters are then regrouped into elements of length size. These elements are assigned to the result matrix, once again in row-major order. If there are not enough characters for the result matrix, the source of the remaining characters depends on whether padding was specified with padchar. If no padding was specified, the source matrix's characters are cycled through again. If a padding character was specified, the remaining characters are all the padding character.
If one of the dimension arguments (nrow, ncol), or size) is zero, the function computes the dimension of the output matrix by dividing the number of elements of the input matrix by the product of the nonzero arguments.
Some examples follow. The statement
r=cshape('abcd',2,2,1);results in
R 2 rows 2 cols (character, size 1) a b c dThe statement
r=cshape('a',1,2,3);results in
R 1 row 2 cols (character, size 3) aaa aaaThe statement
r=cshape({'ab' 'cd', 'ef' 'gh', 'ij' 'kl'}, 2, 2, 3);results in
R 2 rows 2 cols (character, size 3) abc def ghi jklThe statement
r=cshape('XO',3,3,1);results in
R 3 rows 3 cols (character, size 1) X O X O X O X O XAnd finally, the statement
r=cshape('abcd',2,2,3,'*');results in
R 2 rows 2 cols (character, size 3) abc d** *** ***
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.