- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content