| Creating Variables | |
| Assignment
Statements |
| SAS Functions |
You can also use SAS functions in assignment statements. A SAS function
is a prewritten routine that returns a value computed from one or more arguments.
For example, the assignment statement below uses the MEAN function to create
the variable AvgChol by averaging the values of
Chol1 and Chol2.
data lab23.drug1h;
set research.cltrials;
if placebo='YES';
CholChange=chol2-chol1;
glucose=glucose+glucose*.10;
AvgChol=mean(chol1,chol2);
run;
The chart below shows examples of SAS functions. See SAS Language Reference: Dictionary and the SAS OnlineTutor lesson Formatting Data with SAS Functions for more information. |
| Keyword | Description |
|---|---|
| MIN | returns the smallest value of the arguments |
| MAX | returns the largest value of the arguments |
| ROUND | rounds a value to the nearest roundoff unit |
| MEAN | computes the arithmetic mean (average) |
| SUM | calculates the sum of the arguments |
| SCAN | returns a given word from a character expression |
| UPCASE | converts character values to uppercase letters |
![]() ![]() |
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.