Reputation: 1232
I know how to change the format of variables through data step like following.
data want;
set have;
format abc date9.;
run;
But if the format change requires converting from Character to Numeric then to Date involves following code with creation of new variable which I want to avoid.
data want;
set have;
abc_1 = input(scan(abc,"1"),ddmmyy10.);
format abc_1 date9.;
run;
Is it possible to avoid creation of new variable and change Character into Numeric and then Date9.
Upvotes: 0
Views: 454
Reputation: 63434
You can cause a character variable to contain the DATE9.
formatted date value, but you can't have it contain the underlying date value and show a format, no.
abc = put(input(scan(abc,'1'),ddmmyy10.),date9.);
However, it won't be a numeric with a date format. To do that, you have to create a new variable. You can cause it to be written to the dataset with the same name;
data want;
set have;
abc_1 = input(scan(abc,"1"),ddmmyy10.);
format abc_1 date9.;
drop abc;
rename abc_1=abc;
run;
but it still technically creates a new variable (even though you don't really see that in the output).
Upvotes: 2