简体   繁体   中英

SAS: PROC SQL: How to convert a character format column to time format

I have a column which is character format and has entries as hh:mm:ss . How can I convert character format to time format using proc sql in sas?

You should be able to use the input function with a format (time8.) to convert the value. The original column will not change its type from char, so you can create another column to hold the numeric value.

If you need something else then please edit your question with an expanded explanation and an example.

/* set up data */
data have;
   input char_time : $8.;
   datalines;
00:00:00
01:02:03
23:59:59
;

/* create a column in time8. format */
proc sql noprint;
   create table
      want as
   select
       char_time
      ,input(char_time,time8.) as num_time format = time8.
   from
      have
   ;
quit;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM