Reputation: 464
How can I convert dd/mm/yy/ to yy/mm/dd in SAS
I have ACCESS_DATE was something like: 18012019, but needs to be 2019/01/18 I did the following:
,put(ACCESS_DATE, YYMMDDS10.) as 'ACCESS_DATE'n
but this creates: 18/01/2019
So how do I get the yyyy in the front like: yy/mm/dd in SAS EG
Upvotes: 0
Views: 1210
Reputation: 27498
In EG you might be selecting the format from a drop down list. Double check the variable type (num or char) and format (several with y, m & d).
data _null_;
date = '18-JAN-2019'd;
put date @15 'SAS date value';
put date date9. @15 'DATE9. format';
put date date11. @15 'DATE11. format';
put date ddmmyyn8. @15 'DDMMYYN8. format';
put date YYMMDDS10. @15'YYMMDDS10. format';
put date MMDDYYS10. @15'MMDDYYS10. format';
put date DDMMYYS10. @15'DDMMYYS10. format';
run;
----- LOG -----
21567 SAS date value
18JAN2019 DATE9. format
18-JAN-2019 DATE11. format
18012019 DDMMYYN8. format * possibly what you were seeing initially
2019/01/18 YYMMDDS10. format * what is wanted
01/18/2019 MMDDYYS10. format
18/01/2019 DDMMYYS10. format * only way to get what is stated in question
Upvotes: 1