Hi all,
im having some issues changing one of my variables from Character ($CHAR1.) to numeric (BEST12.) so that I can append it to another table. The variable's format that im trying to change is a pre-existing variable within the dataset.
Here is my current code:
data work.test2;
set work.test;
SYD=input(SYD,BEST12.);
run;
when I run this code, I dont get any errors or warnings however the variable doesn't change formats.
Any suggestions on what I can do?
Thanks!
Variables can't change their type. But you can work around it:
data work.test2;
set test;
newvar = input(SYD, best12.);
drop SYD;
rename newvar = SYD;
run;
Variables can't change their type. But you can work around it:
data work.test2;
set test;
newvar = input(SYD, best12.);
drop SYD;
rename newvar = SYD;
run;
Is the following NOTE being output to the log?
This means that an implicit conversion is taking place because the result of converting SYD to a number with the input function is stored in a character variable.
Since SAS does not allow variable type change, rename is required as follows.
data work.test2(drop=_SYD);
set work.test(rename=(SYD=_SYD));
SYD=input(_SYD,BEST12.);
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.