1

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.

MAJ Les
  • 13
  • 1
  • 1
  • 4

1 Answers1

3

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.
Chris J
  • 7,549
  • 2
  • 25
  • 25