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

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