02-25-2013 04:53 PM
Hi SAS Forum,
The variable named “account_number” in dataset A is a numeric (it is sure).
I wanted to convert it into a character.
I used this code.
data B (rename=(account_number_new=account_number));
account_number_new=left(put(account_number, $32.)); /*to convert to character;*/
This warning comes but conversion happened.
WARNING: Variable ACCOUNT_NUMBER has already been defined as numeric.
Could anyone help me to understand why this warning?
02-25-2013 07:11 PM
You're going to get the warning regardless, but you should be able to ignore it. If your PROC Contents shows the variable you want coming out as character, you're doing fine.
02-25-2013 07:28 PM
Duh! <smacks self on head> Tom is totally right.
You're using a character informat and applying it to a numeric variable. The informat that you use in your PUT function should be the same variable type as the incoming source data (in this case numeric). It will still output the new variable as character.
What I said was also technically kind of true, but that's just because SAS was being nice and forgiving, not because your code was technically correct.
Need further help from the community? Please ask a new question.