data _null_;
format var_fmt ddmmyy10.;
var_num = 42;
var_fmt = 4242;
/* Named put, format is applied: */
put var_num= var_fmt=; /* var_num=42 var_fmt=13/08/1917 */
/* Column put, format is not applied: */
put var_num 1-10 var_fmt 13-23; 42 4242 */
run;
With formatted put, a format can by dynamically applied to a variable in a put statement:
data _null_;
val=4242;
put val; /* 4242 */
put val deudfdd10.; /* 13.08.1917 */
put val time10.; /* 1:10:42 */
/* Combining named and formatted put: */
put val=; /* val=4242 */
put val= deudfdd10.; /* val=13.08.1971 */
put val= time10.; /* val=1:10:42 */
run;
During the subsequent executions of put statement, SAS maintains a column and a line pointer that control where the output of the next put statement goes to.
The column pointer is moved to a specific column with @expression. expression can be, for example a constant (@42), the value of a variable @var or the result of an expression within parenthesis: @(foo+bar+3).
The column pointer can be moved relatively with +expression.
The line pointer can be moved to a specific line with #expression.
The line pointer is moved to the next line with /.
expression
/* +(expr) moves the pointer to the column expr. */
data _null_;
do pos=1 to 20;
put +(pos) '*';
end;
run;
data _null_;
/* A trailing at sign (line-hold specifier) does not put
a new-line (carriage return), the next the put write
on the same line */
put "foo" @;
put "bar" @;
put "baz";
put "one" @;
put "two" @;
put "three";
run;
data _null_;
array fib[10];
fib[1] = 0;
fib[2] = 1;
do i = 3 to dim(fib);
fib[i] = fib[i-2] + fib[i-1];
end;
* put each element of array fib ;
put (fib[*]) (=);
* put some selected elements of array ;
put (fib4 fib7 fib8) (=);
* put values on seperate lines ;
put (fib[*]) (=/);
run;