BookmarkSubscribeRSS Feed
KevinC_
Fluorite | Level 6
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
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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;
ChrisNZ
Tourmaline | Level 20
Or you could skip n fields by reading past them:
[pre]
input var1-varn $ @;
drop var:;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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