Syntax, assignment statement:
variable=expression;
Tip:The assignment statement is
one of the few SAS statements that do not begin with a keyword.
|
Toby
Witherspoon
to the variable Name: Name='Toby Witherspoon';
Operator
|
Action
|
Example
|
Priority
|
---|---|---|---|
-
|
negative prefix
|
negative=-x; |
I
|
**
|
exponentiation
|
raise=x**y; |
I
|
*
|
multiplication
|
mult=x*y; |
II
|
/
|
division
|
divide=x/y; |
II
|
+
|
addition
|
sum=x+y; |
III
|
-
|
subtraction
|
diff=x-y; |
III
|
Operator
|
Meaning
|
Example
|
---|---|---|
= or eq
|
equal to
|
name='Jones, C.' |
^= or ne
|
not equal to
|
temp ne 212 |
> or gt
|
greater than
|
income>20000 |
< or lt
|
less than
|
partno lt "BG05" |
>= or ge
|
greater than or equal
to
|
id>='1543' |
<= or le
|
less than or equal to
|
pulse le 85 |
Operator, symbol
|
Description
|
---|---|
AND or &
|
and, both. If both expressions
are true, then the compound expression is true.
|
OR or |
|
or, either. If either
expression is true, then the compound expression is true.
|
data sasuser.stress;
infile tests;
input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
RecHR 35-37 TimeMin 39-40 TimeSec 42-43
Tolerance $ 45;
TotalTime=(timemin*60)+timesec;
run;
data sasuser.stress;
infile tests;
input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
RecHR 35-37 TimeMin 39-40 TimeSec 42-43
Tolerance $ 45;
resthr=resthr+(resthr*.10);
run;
data sasuser.stress; infile tests; input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33 RecHR 35-37 TimeMin 39-40 TimeSec 42-43 Tolerance $ 45; resthr=resthr+(resthr*.10); run; ^ ^ result original value
Syntax, date constant:
'ddmmmyy'd
'ddmmmyy'd
Tip:Be sure to enclose the date
in quotation marks.
|
data sasuser.stress;
infile tests;
input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
RecHR 35-37 TimeMin 39-40 TimeSec 42-43
Tolerance $ 45;
TotalTime=(timemin*60)+timesec;
TestDate='01jan2015'd;
run;
Time='9:25't; DateTime='18jan2015:9:27:05'dt;