If you define a numeric variable and assign the result of a character expression to it, SAS tries to convert the character result of the expression to a numeric value and to execute the statement. If the conversion is not possible, SAS prints a note to the log, assigns the numeric variable a value of missing, and sets the automatic variable _ERROR_ to 1. For a listing of the rules by which SAS automatically converts character variables to numeric variables and vice-versa, see "Automatic Numeric-Character Conversion" on page 116.
If you define a character variable and assign the result of a numeric expression to it, SAS tries to convert the numeric result of the expression to a character value using the BEST w. format, where w is the width of the character variable and has a maximum value of 32. SAS then tries to execute the statement. If the character variable you use is not long enough to contain a character representation of the number, SAS prints a note to the log and assigns the character variable asterisks . If the value is too small, SAS provides no error message and assigns the character variable the character zero (0).
4 5 data _null_; 6 x= 3626885; 7 length y $ 4; 8 y=x; 9 put y; 36E5 NOTE: Numeric values have been converted to character values at the places given by: (Number of times) at (Line):(Column). 1 at 8:5 10 data _null_; 11 xl= 3626885; 12 length yl $ 1; 13 yl=xl; 14 xs=0.000005; 15 length ys $ 1; 16 ys=xs; 17 put yl= ys=; 18 run; NOTE: Invalid character data, XL=3626885.00 , at line 13 column 6. YL=* YS=0 XL=3626885 YL=* XS=5E-6 YS=0 _ERROR_=1 _N_=1 NOTE: Numeric values have been converted to character values at the places given by: (Number of times) at (Line):(Column). 1 at 13:6 1 at 16:6
In the first DATA step of the example, SAS is able to fit the value of Y into a 4-byte field by representing its value in scientific notation. In the second DATA step, SAS cannot fit the value of YL into a 1-byte field and displays an asterisk (*) instead.