BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kli
Calcite | Level 5 kli
Calcite | Level 5

Hello:

 

I have a column of csv data as following:

 

2020/09/11 02:14:27

2020/09/11 02:15:37

2020/09/11 02:16:08

 

During import SAS convert the column to Type Char instead of DATETIME.

 

How can I manually convert this column into SAS DATETIME format.

 

Thanks in advance,

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  If you use a DATA step program you can control how the variable is read and then deal with the date/time value as you wish. The ANYDTDTM informat allows you to read date/time values as you show in your example.

Cynthia_sas_0-1600795914364.png

 

Hope this helps,

Cynthia

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  If you use a DATA step program you can control how the variable is read and then deal with the date/time value as you wish. The ANYDTDTM informat allows you to read date/time values as you show in your example.

Cynthia_sas_0-1600795914364.png

 

Hope this helps,

Cynthia

Tom
Super User Tom
Super User

CSV files are just text files. So there is no need to "import" them.  Just write a data step to READ the file instead. Then you have complete control over how each variable is defined.

data want;
  infile cards dsd ;
  input dt :anydtdtm. ;
  format dt datetime19.;
cards;
2020/09/11 02:14:27
2020/09/11 02:15:37
2020/09/11 02:16:08
;
Obs                     dt

 1      11SEP2020:02:14:27
 2      11SEP2020:02:15:37
 3      11SEP2020:02:16:08

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 711 views
  • 4 likes
  • 3 in conversation