BookmarkSubscribeRSS Feed
Hansmuffs
Fluorite | Level 6

Hi,

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

17.02.22  08:06

This is not working:

format BEGINN_TMP DATETIME19.;
BEGINN_TMP = input(BEGINN, DATETIME19.);
1 REPLY 1
FreelanceReinh
Jade | Level 19

Hi @Hansmuffs,

 

With the usual German locale

options locale=DE_DE;

this works:

data have;
string='17.02.22  08:06';
run;

data want;
set have;
dt=input(string, nldatm.);
format dt nldatms14.;
run;

except for the year 2000 (!). So, better use 4-digit years, as we've learned end of last century.

 

Documentation of the surprising Y2K issue of the NLDATMw. informat :

data _null_;
input dt nldatm.;
put dt nldatms14.;
cards;
17.02.98 08:06
17.02.99 08:06
17.02.00 08:06
17.02.01 08:06
17.02.02 08:06
;

Log (Windows SAS 9.4M5 with locale DE_DE and YEARCUTOFF=1926):

753   data _null_;
754   input dt nldatm.;
755   put dt nldatms14.;
756   cards;

17.02.98 08:06
17.02.99 08:06
NOTE: Invalid data for dt in line 759 1-19.
             .
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
759         17.02.00 08:06
dt=. _ERROR_=1 _N_=3
17.02.01 08:06
17.02.02 08:06
NOTE: DATA statement used (Total process time):

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 215 views
  • 0 likes
  • 2 in conversation