@Dynamike wrote:
thank you! That works!
But, if there is more than one instring e.g.
"2017-01-01 00:00:00"
"2018-03-25 00:00:00"
"2016-05-03 00:00:00"
my solution would be:
DATA Test_Out;
LENGTH tod_datum $ 10;
FORMAT tod_datum yymmddd10.;
INFORMAT tod_datum yymmddd10.;
INFILE 'C:\Test_In.csv'
delimiter=','
MISSOVER
firstobs=2
DSD
LRECL=32767;
INPUT tod_datum : ?? $CHAR23.
RUN;
Data test_out;
Set test_out;
todtag=input(tod_datum,yymmdd10.);
format todtag ddmmyy10.;
run;
This works, but is there no direct way? informat not as a string, but another date format (E8601DTw.d seems to be similar, but does not work).
Or is there another way to avoid the second data step?
Thank u for ur effort!
Mike
Why did you go to the trouble of setting a character length and then assigning numerical informat and formats and then forcing it to be read as character? Also the informat you want is likely
YYMMDD10 not YYMMDDD10. The informat does not want or need the separator provided.
If you want an actual SAS date value then this should work
DATA Test_Out;
FORMAT tod_datum yymmddd10.;
INFORMAT tod_datum yymmdd10.;
INFILE 'C:\Test_In.csv' delimiter=',' MISSOVER firstobs=2 DSD
LRECL=32767;
INPUT tod_datum .
RUN;
If you want a CHARACTER value then just read the number of characters but the mishmash of code makes it hard to tell which you actually want.