BookmarkSubscribeRSS Feed
bhca60
Quartz | Level 8

How do I convert to character from numeric. I am joining two tables and need them to BOTH be character.  I have tried the following and it is not converting:

 

data p_b; 
set p.pcl ;
new_char = put(mednbr, 8.);
run;

 I have also tried input: new_char= put(input(mednbr, 8.));

that doesnt work either......

 

 

1 REPLY 1
Tom
Super User Tom
Super User

@bhca60 wrote:

How do I convert to character from numeric. I am joining two tables and need them to BOTH be character.  I have tried the following and it is not converting:

 

data p_b; 
set p.pcl ;
new_char = put(mednbr, 8.);
run;

 I have also tried input: new_char= put(input(mednbr, 8.));

that doesnt work either......


FORMATs convert values to TEXT.

INFORMATs convert TEXT to values.

 

You need to use a numeric INFORMAT with an INPUT() function call to convert characters string with TEXT into a numeric VALUE. 

 

Note that the INPUT() function does not care if the WIDTH of the informat specification used is larger than the LENGTH of the character string being read.  32 is the maximum number of bytes that the numeric informat can consume.

new_char = input(mednbr, 32.);