Hello
I want to convert numeric into char.
The problem is that the missing numeric values are converted into '.' and I want to have '' (without period).
I can write a statement IF C_char='.' then C_char='';
But my question if there is another way to do it?
data have;
input x;
cards;
100
200
.
300
.
600
;
Run;
data want;
set have;
x_char=put(x,best.);
x_char2=put(x,8.-L);
Run;
First, I would try
options missing=" ";
but I can't test in the moment if this also works for PUT functions.
Or you use a custom format:
proc format;
value mybest
. = " "
other = [best.]
;
run;
data want;
set have;
x_char=put(x,mybest.);
run;
First, I would try
options missing=" ";
but I can't test in the moment if this also works for PUT functions.
Or you use a custom format:
proc format;
value mybest
. = " "
other = [best.]
;
run;
data want;
set have;
x_char=put(x,mybest.);
run;
The idea of converting numeric to character just so you can change the appearance of a value bothers me. When you want to change the appearance of something, you use a custom format or a built-in SAS format. It seems that this conversion from numeric to character isn't necessary, it's extra work with no apparent benefit.
Using the custom format from @Kurt_Bremser , this works without the unnecessary step of changing from numeric to character:
proc print data=have;
var x;
format x mybest.;
run;
As stated many times already, @Ronein , please test your code before posting it. The code you posted generated errors.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.