Using SAS 9.4
I am having trouble converting numeric data into character data. I am using the following code:
data want;
set have;
med2_dose = input(med2_dose, 6.);
run;
The data are purely numbers (ie 1, 20, 25, 100, 250, etc.)
Whenever I run this code all of the numeric data is lost in the new variable but it is converted to character. Does anyone know how to correct this? Thank you
Converting numeric to character uses the PUT function, not the INPUT function. You also have to name the resulting character variables something different than the original numeric variable.
Why on earth would you want dose to be character and not numeric?
Converting numeric to character uses the PUT function, not the INPUT function. You also have to name the resulting character variables something different than the original numeric variable.
Why on earth would you want dose to be character and not numeric?
I am combining 2 data sets and I need the variables to be the same (character or numeric) in order to stack the data sets together. However, in one of the data sets dose is a character because of the way the data was enter 10/325 for example.
@GS2 wrote:
I am combining 2 data sets and I need the variables to be the same (character or numeric) in order to stack the data sets together. However, in one of the data sets dose is a character because of the way the data was enter 10/325 for example.
Had I known that, I would have provided a different solution. Convert the character variable to be numeric. Then "combining" the two data sets will be possible, and dose will have the usefulness that you can analyze it as a number.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.