Chapter Contents |
Previous |
Next |
Command Directory |
Assign a Value to an Expression
a{ssign}
Format 1: assign SCALAR-TYPE-EXPRESSION
= VALUE | |
Format 2: assign AGGREGATE-TYPE-EXPRESSION
= 1 {VALUE-LIST}| AGGREGATE-TYPE-EXPRESSION |
assign
command assigns the value (or values) specified by VALUE, VALUE-LIST, or AGGREGATE-TYPE-EXPRESSION
to the expression identified by SCALAR-TYPE-EXPRESSION or AGGREGATE-TYPE-EXPRESSION.
In both formats, the equal sign is required.
VALUE is an expression whose type is one of the following:
See Debugger Variables for details on argument types that are used with the
assign
command. If the VALUE argument and the SCALAR argument have
different types, a conversion is made according to the SAS/C
Compiler's rules for conversions.
The VALUE-LIST argument can also be used to assign values
to the target AGGREGATE-TYPE-EXPRESSION. Any of the items in a VALUE-LIST
can be a structure or union. If a union is specified, VALUE-LIST must contain
exactly one item that is assigned to the first member of the union. For example,
in the following statement, 5 is assigned to the first member of
some_union
:
assign some_union = { 5 }
To assign a value (for example, 9) to the second member
of
some_union
, use assign
as follows:
assign some_union.member2 = 9
The AGGREGATE-TYPE-EXPRESSION argument can be a structure with members that are aggregates.
The VALUE-LIST argument contains any or all of the following items, enclosed by braces:
Format 1
) separated by commas:
{VALUE, VALUE, VALUE, . . .} |
Rules for assigning VALUE-LISTs to aggregate objects:
struct a { int b; struct ccc d; long e; };
The structure needs a VALUE-LIST, as follows, with the
values to be assigned to
struct ccc d
in the inside set of
braces:
{b-value, {d-value, d-value, d-value, . . .}, e-value}
assign
examples in this section are based on the following declarations and
#define
statement:
#define B_MAX 9 int ival; char *p; struct XXX int a; short b,c;d;
The semantics in the examples are the same as for the
assignment statement. In other words, assign i=5
does the same as i=5;
in C.
assign ival = 3+B_MAX
ival
.
assign p =
&ival
ival
to a pointer object
(scalar).
assign ival = 20
assign d = {1,2}
d
(d.a=1,d.b=2
)
.
assign d = {1,ival,3}
d
(d.a=1,d.b=20,d.c=3
).
assign d = {d.b}
d.b
(a short) to the first element of structure d
(d.a =20
).
PROFILE | no |
configuration file | no |
Source window prefix | none |
assign
command uses command scope to resolve references to all identifiers.
Successful: 0 | |
Unsuccessful: 1 |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.