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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.