Transforming Data with SAS Functions | |
Converting Data with Functions |
Explicit Numeric-to-Character Conversion
Using the PUT function, you can explicitly convert numeric data values to character data values.
Let's use this function to complete one of the modifications needed for the
data set Hrd.Temp. Suppose you are asked to create a new
character variable named |
SAS Data Set Hrd.Temp
Overtime | Job | Contact | Department | Site |
4 | Word processing | Word Processor | DP | 26 |
. | Filing, administrative duties | Admin. Asst. | PURH | 57 |
. | Organizational dev. specialist | Consultant | PERS | 34 |
. | Bookkeeping, word processing | Bookkeeper Asst. | BK | 57 |
To concatenate the values, you write an assignment statement that contains
the concatenation operator, ||, to indicate that Site should
be concatenated with a slash and then concatenated with Department .
Note that the slash appears in quotation marks. All character constants must
be specified in quotation marks.
data hrd.newtemp; set hrd.temp; Assignment=site||'/'||department; run;
You know that submitting this DATA step will cause SAS software to automatically
convert the numeric values of |
General form, PUT function:
where
|
Because you are listing a numeric variable as the source, you must specify a numeric format. |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.