Transforming Data with SAS Functions | |
Converting Data with Functions |
Now that you know the general form of the PUT function, you can rewrite
the assignment statement in your DATA step to explicitly convert the numeric
values of Site to character values.
To perform this conversion, write the PUT function by specifying
data hrd.newtemp; set hrd.temp; Assignment=put(site,2.)||'/'||department; run; |
SAS Data Set Hrd.Newtemp
Overtime | Job | Contact | Department | Site | BirthDate | Assignment |
4 | Word processing | Word Processor | DP | 26 | 7054 | 26/DP |
. | Filing, administrative duties | Admin. Asst. | PURH | 57 | 5757 | 57/PURH |
Notice that no conversion messages appear in the SAS log when using the PUT function. |
SAS Log
13 data hrd.newtemp; 14 set hrd.temp; 15 Assignment=put(site,2.)||'/'||department; 16 run; |
Matching the Data Type
Remember that the format specified in the PUT function must match the data type of the source. PUT(source,format) So, to do an explicit numeric-to-character data conversion, you specify a numeric source and a numeric format. The form of the PUT function is very similar to the form of the INPUT function. PUT(source,format) Note that the PUT function requires a format, whereas the INPUT function requires an informat. To remember which function requires a format versus an informat, note that the INPUT function requires the informat. |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.