Help using Base SAS procedures

Append data to the end of each row

Reply
Regular Contributor
Posts: 173

Append data to the end of each row

Hello all,

I have a delimited input file with close to 100 fields. i would like to append data to the end of each row. But i don't want to define each of the 100 fields in the input section. in addition, since it's a delimited file, each row has different length. Is there a way to skip to the end of each row from an input file when reading it?

Thanks for any input!
kevin
Super Contributor
Super Contributor
Posts: 3,174

Re: Append data to the end of each row

Using a DATA step, it is possible to read up the current data record using an INFILE and INPUT statement, and then address it with the SAS reserved variable _INFILE_ for whatever purpose you might require. A very simple SAS DATA step is listed below for your review/consideration.

Also, the INFILE statement has parameters you can code to identify the record length, current column pointer location -- review the SAS Language INFILE discussion for details.

Scott Barry
SBBWorks, Inc.

data _null_;
infile datalines dsd truncover dlm=',';
input @;
putlog _all_ / _infile_;
cards;
a,b,c,d
e,f,g,h
run;
PROC Star
Posts: 1,760

Re: Append data to the end of each row

Or you could skip n fields by reading past them:
[pre]
input var1-varn $ @;
drop var:;
Ask a Question
Discussion stats
  • 2 replies
  • 94 views
  • 0 likes
  • 3 in conversation