BookmarkSubscribeRSS Feed
San_rise
Fluorite | Level 6

I am trying to import a pipe '|' delimited text file in SAS using PROC IMPORT. Though I am able to get most of the variable values except the date variable having value as '2020-07-14 11:00 EDT'. Please guide on how to handle this data.

 

Also please guide on various must use options while importing a text file so that no variables or values get missed out.

 

Thanks

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

> please guide on various must use options while importing a text file so that no variables or values get missed out.

This means not using proc import, but rather using a data step and an INFILE statement.

This will also allow you to process the date and time correctly.

Many resources on the web such as since one https://support.sas.com/techsup/technote/ts673.pdf

San_rise
Fluorite | Level 6

Please help by specifying the format and informat for the date value 2020-07-14 11:00 EDT (YYYY-MM-DD HH:MM ZONE)

Kurt_Bremser
Super User

See this:

proc format;
invalue ustz
  "AST" = 14400 /* ATLANTIC STANDARD TIME UTC - 4 */
  "EST" = 18000 /* EASTERN STANDARD TIME  UTC - 5 */
  "EDT" = 14400 /* EASTERN DAYLIGHT TIME  UTC - 4 */
  "CST" = 21600 /* CENTRAL STANDARD TIME UTC - 6 */
  "CDT" = 18000 /* CENTRAL DAYLIGHT TIME UTC - 5 */
  "MST" = 25200 /* MOUNTAIN STANDARD TIME  UTC - 7 */
  "MDT" = 21600 /* MOUNTAIN DAYLIGHT TIME  UTC - 6 */
  "PST" = 28800 /* PACIFIC STANDARD TIME UTC - 8 */
  "PDT" = 25200 /* PACIFIC DAYLIGHT TIME UTC - 7 */
  "AKST" = 32400 /* ALASKA TIME UTC - 9 */
  "AKDT" = 28800 /* ALASKA DAYLIGHT TIME  UTC - 8 */
  "HST" = 36000 /* HAWAII STANDARD TIME  UTC - 10 */
  "HAST" = 36000 /* HAWAII-ALEUTIAN STANDARD TIME UTC - 10 */
  "HADT" = 32400 /* HAWAII-ALEUTIAN DAYLIGHT TIME UTC - 9 */
  "SST" = 39600  /* SAMOA STANDARD TIME UTC - 11 */
  "SDT" = 36000 /* SAMOA DAYLIGHT TIME UTC - 10 */
  "CHST" = -36000 /* CHAMORRO STANDARD TIME  UTC +10 */
  other = 0
;

data want;
infile datalines;
input dttime e8601dt16. zone :$4.;
format dttime e8601dt19.;
dttime = dttime + input(zone,ustz.);
drop zone;
datalines;
2020-07-14 11:00 EDT
;

The result will be the datetime in UTC.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 3 replies
  • 770 views
  • 1 like
  • 3 in conversation