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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

5 REPLIES 5
art297
Opal | Level 21

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.

AliMN
Calcite | Level 5

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

art297
Opal | Level 21

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;

AliMN
Calcite | Level 5

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.

art297
Opal | Level 21

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 5 replies
  • 656 views
  • 0 likes
  • 2 in conversation