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):

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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