How to transform SAS String Value into Timestamp?

Viewed 83

how to transform this string value into a timestamp format like dd.mm.yyyy hh:mm?

17.02.22  08:06 (Format dd.mm.yy  hh:mm)

This is not working:

format BEGINN_TMP DATETIME19.;
BEGINN_TMP = input(BEGINN, DATETIME19.);
1 Answers

That is because the string's format is not in datetime. format. datetime. looks as follows:

22FEB17:08:06:00

We'll use the anydtdtm. informat to read it, which automatically tries a variety of time formats to find the right one.

data want;
    string   = '17.02.22  08:06';
    datetime = input(string, anydtdtm.);
    
    format datetime datetime.;
run;

Output:

string               datetime
17.02.22  08:06      22FEB17:08:06:00
Related