- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content