Reading tab delimited file using SAS

Accepted Solution Solved
Reply
Contributor
Posts: 50
Accepted Solution

Reading tab delimited file using SAS

Hi all

I am trying to read a tab delimited file from Mainframes in AIX via SAS FTP. I am using the following FILENAME statement:

FILENAME FTP TEST "'TEST.FILENAME.ABC'" HOST="HSSS.SYS.XYZ.COM" USER="USERN" PASS="PASSWORD";

DATA TEST;

INFILE TEST DLM='05'X DSD MISSOVER TRUNCOVER;

INPUT YEAR $4

          M0      $2

          NAME $4

          CODE $6;

RUN;

I am using these statements inside Unix (AIX). The DLM statements seem to have no effect while reading. Here '05'x refers to hexa value of tab in EBCDIC (Mainframes). I tried using '09'x as well as hexa is represented by '09'x in ASCII (Unix).

But none of them seem to have effect on the input file.

Is anyone aware of reading tab delimited files via FTP from Mainframes on Unix.

Any help in this regard would be highly appreciated.

Thanks.


Accepted Solutions
Solution
‎07-28-2013 07:21 PM
Super User
Super User
Posts: 7,062

Re: Reading tab delimited file using SAS

If you are reading a delimited file you should not use formatted input style as it could read right past the delimiter or stop short and throw off breaking the line up at the delimiters.  Unless you specify BINARY on the FTP then the file will be converted to ASCII, since you are reading the character variables as ASCII instead of EBCDIC then you should use '09'x for the delimiter. There is almost never a case when you want to use MISSOVER option instead of the TRUNCOVER option. Plus your code is not using it anyway as you have overridden it by adding the TRUNCOVER option.

DATA TEST;

  INFILE TEST DLM='09'X DSD TRUNCOVER;

  LENGTH YEAR $4 M0 $2 NAME $4 CODE $6 ;

  INPUT YEAR M0 NAME CODE ;

RUN;

View solution in original post


All Replies
Super User
Super User
Posts: 7,062

Re: Reading tab delimited file using SAS

First look at what is actually in the file.  Add a LIST statement after the INPUT and SAS will show you what it has received. Any non printable characters such as a tab will cause SAS to list the actual hex values of the characters.

RULE:     ----+----1----+----2----+----3

1   CHAR  Alfred.M.14.69.112.5 20

    ZONE  46676604033033033323

    NUMR  1C62549D9149699112E5

2   CHAR  Alice.F.13.56.5.84 18

    ZONE  466660403303323033

    NUMR  1C93596913956E5984


3   CHAR  Barbara.F.13.65.3.98 20

    ZONE  46766760403303323033

    NUMR  212212196913965E3998


NOTE: 3 records were read from the infile TMPFILE2.

Solution
‎07-28-2013 07:21 PM
Super User
Super User
Posts: 7,062

Re: Reading tab delimited file using SAS

If you are reading a delimited file you should not use formatted input style as it could read right past the delimiter or stop short and throw off breaking the line up at the delimiters.  Unless you specify BINARY on the FTP then the file will be converted to ASCII, since you are reading the character variables as ASCII instead of EBCDIC then you should use '09'x for the delimiter. There is almost never a case when you want to use MISSOVER option instead of the TRUNCOVER option. Plus your code is not using it anyway as you have overridden it by adding the TRUNCOVER option.

DATA TEST;

  INFILE TEST DLM='09'X DSD TRUNCOVER;

  LENGTH YEAR $4 M0 $2 NAME $4 CODE $6 ;

  INPUT YEAR M0 NAME CODE ;

RUN;

Contributor
Posts: 50

Re: Reading tab delimited file using SAS

Awesome! It worked perfect!  So insightful! Thank you!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 2844 views
  • 0 likes
  • 2 in conversation