Reading txt file in SAS does not show all columns

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

Reading txt file in SAS does not show all columns

I’ve a text file that Im reading in SAS and for some reason the last column (Year_2013) in the file is not populated (blank). I tried to format but it's not taking. The file consists 4 columns. id_cust has character rows and all Year columns has dollar rows. Here’s my SAS code. Any help is appreciated.

data work.rev;

     INFILE "/vendorlst.txt"

           DELIMITER='09'x

           MISSOVER

           DSD

           LRECL=32767

           FIRSTOBS=2;

LENGTH

     id_cust $200;

INPUT

           Vndr_id_cust $

           Year_2011

           Year_2012

           Year_2013;

RUN;


Accepted Solutions
Solution
‎01-28-2014 03:01 PM
PROC Star
Posts: 7,366

Re: Reading txt file in SAS does not show all columns

Your example is space not tab delimited.  If that is what your data really look like, the following changes would do what you want.  While I changed missover to truncover, that decision will really depend on what your data really look like.

data work.rev;

  INFILE "/vendorlst.txt"

  truncOVER

  LRECL=32767

  FIRSTOBS=2;

  length

     id_cust $200;

INPUT  id_cust &

       Year_2011

       Year_2012

       Year_2013;

RUN;

View solution in original post


All Replies
PROC Star
Posts: 7,366

Re: Reading txt file in SAS does not show all columns

Can you provide a sample of your dataset say, e.g., maybe the first 5 or 10 rows?

One problem is that you define a length for a variable (id_cust), but never use it, but use vndr_id_cust instead.

Contributor
Posts: 49

Re: Reading txt file in SAS does not show all columns

Thanks, Arthur. To correct on my previous post due typo error. id_cust is same as Vndr_id_cust.

Here’s an example of the Input file in txt file I'm using

Vndr_id_cust     Year_2011           Year_2012           Year_2013

ABC CORPORATION       85032386.25       123252387.54     110031088.50

SAS output Result

Capture.JPG

Solution
‎01-28-2014 03:01 PM
PROC Star
Posts: 7,366

Re: Reading txt file in SAS does not show all columns

Your example is space not tab delimited.  If that is what your data really look like, the following changes would do what you want.  While I changed missover to truncover, that decision will really depend on what your data really look like.

data work.rev;

  INFILE "/vendorlst.txt"

  truncOVER

  LRECL=32767

  FIRSTOBS=2;

  length

     id_cust $200;

INPUT  id_cust &

       Year_2011

       Year_2012

       Year_2013;

RUN;

Contributor
Posts: 49

Re: Reading txt file in SAS does not show all columns

Thanks a lot, Arthur! That solved my issues. There's a column in the file that I would like to break it as follows.

Capture.JPG

Now, the file has Vndr_id_cust column and I would like the vndr_id and cust to be seperated in two columns (e.g: vndr_id and Cust). Any help is appreciated.

PROC Star
Posts: 7,366

Re: Reading txt file in SAS does not show all columns

: It would be easiest to do that up front in the data step where you are reading the data:

data work.rev;

  INFILE "/vendorlst.txt"

  truncOVER

  LRECL=32767

  FIRSTOBS=2;

  length id $10

         cust $200;

INPUT  id

       @'- ' cust &

       Year_2011

       Year_2012

       Year_2013;

RUN;

🔒 This topic is solved and locked.

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

Discussion stats
  • 5 replies
  • 287 views
  • 0 likes
  • 2 in conversation