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

Hello everyone,

I'm facing an issue with reading datetime and timezone value into SAS as a character.

 

data a;
input abc : $100.;
informat abc $100.;
format abc $100.;
cards;
2023-11-11 11:06:35.140028 America/New_York
;
run;

 

When I execute the above, SAS is not reading the entire value. It is just reading the date. Could anyone please help.

 

Thanks so much.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Because you told it to use LIST MODE input by using the colon modifier in the INPUT statement it stopped at the first delimiter character, space.  Use FORMATTED MODE input.  But you might want to add an INFILE statement so you can add the TRUNCOVER option since data lines are a always a multiple of 80 bytes long.

 

Note there is no need to attach either an informat or a format to that variable.  SAS does not need to be given special instructions for how to read or write normal strings.

data a;
  infile cards truncover;
  input abc $100.;
cards;
2023-11-11 11:06:35.140028 America/New_York
;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

Because you told it to use LIST MODE input by using the colon modifier in the INPUT statement it stopped at the first delimiter character, space.  Use FORMATTED MODE input.  But you might want to add an INFILE statement so you can add the TRUNCOVER option since data lines are a always a multiple of 80 bytes long.

 

Note there is no need to attach either an informat or a format to that variable.  SAS does not need to be given special instructions for how to read or write normal strings.

data a;
  infile cards truncover;
  input abc $100.;
cards;
2023-11-11 11:06:35.140028 America/New_York
;

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
  • 391 views
  • 0 likes
  • 2 in conversation