I have a dataset with a variable, start date, which takes a lot of different values using a character format.
I have split the dataset up using the values in the start date column, because I want to transform the date variable into two new columns with two different date values:
if length(Startvalue) = 6 then output a6;
else if length(Startvalue) = 8 then output a8 ;
else if length(Startvalue) = 1 then output a1;
else output a_other;
One value is written like this: 090209 (DDMMYY)
I want to format the variable into both a date9. format and a DDMMYYD10. format like this:
FORMAT Startvalue2 date9.;
format Startvalue3 DDMMYYD10.;
I got it to work with this approach in a data step:
FORMAT Startdato2 date9.;
format startdato3 DDMMYYD10.;
Startdato2 = INPUT(PUT(Startdato,6.),DDMMYY6.);
Startdato3 = INPUT(PUT(Startdato,6.),DDMMYY6.);
Another value is written like this: 15-08-17 (DD-MM-YY) I also want the two formats on this value, like this:
FORMAT Startvalue2 date9.;
format Startvalue3 DDMMYYD10.;
BUT here I cannot use a copy of my expression from above:
FORMAT Startvalue2 date9.;
format Startvalue3 DDMMYYD10.;
Startvalue2 = INPUT(PUT(Startvalue,8.),DDMMYYDw.);
Startvalue3= INPUT(PUT(Startvalue,8.),DDMMYYDw.);
Do you know why? And how I can get the value transformed into a date9. format and a DDMMYYD10 format?
Kind regards
Maria