Reputation: 13
I still can't believe this is not working after reading the examples and answers on here.
I have a numeric variable with say the value 20160101.
This needs to be 2016-01-01.
My code... input(put(numvar, Z8.), yymmdd10.) as datevar
OK, the result is 20454
What is more frustrating is when I try this in two different steps. The put(numvar, Z8.) works, but then trying to covert to date ALWAYS ends up back in numeric form.
Upvotes: 1
Views: 12783
Reputation: 7769
You have the correct method to convert the number to a proper SAS date, it's just unformatted.
Try the below, which leaves it as a SAS date, but applies the format you want :
input(put(numvar, Z8.), yymmdd10.) as datevar format=yymmdd10.
Upvotes: 3