02-17-2018 07:28 AM
You cannot convert a numeric variable to character.
You can make a new character variable from a numeric variable.
char_var = put ( num_var, 5.);
or use whatever format works in your case
02-17-2018 09:39 AM - edited 02-17-2018 09:40 AM
The 5. is a FORMAT -- it is the format that SAS uses to make the conversion. So, for example, if you have this zip=123 and you want to make charzip = 00123 as a character variable then you would use the z5. format, like this:
charzip = put(zip,z5.);
Or, if you have this: area=303 and you want this: char_area (303), then you would do:
char_area=catt('(',put(area,3.),')'); (concatenate the ( and ) with the character string 303 after the PUT function.
We teach about the PUT and INPUT functions and variable conversions in the Programming 2 class.
02-19-2018 02:45 AM
new_breed=breed*1 triggers auto-converting "breed" to numeric so that the multiplication is possible. If you are sure, that an char-variable can be converted to numeric, use the input-function. That way you don't get tons of notes in the log and with the proper format you can convert non-english numbers to numbers.
data demo; a = '1.016,052'; b = input(a, commax15.); run;