BookmarkSubscribeRSS Feed
MatthewKelley
Calcite | Level 5

I am trying to create a SAS table from a flat file while excluding headers. Currently I have set the writer to start on line two. However it still pulls my headers from line one.

 

Is there an easy solution to creating a SAS table from a flat file without reading in headers?

5 REPLIES 5
art297
Opal | Level 21

One suggestion: bypass the import task and simply submit the desired code. e.g., if it's 3 numeric columns:

data want;
  infile '/folders/myfolders/testdata.txt' firstobs=2;
  input col1-col3;
run;

Art, CEO, AnalystFinder.com

 

 

Reeza
Super User

Are you using DI Studio or SAS Base?

 

If you're using SAS BASE you can try the datarow option in PROC IMPORT or FIRSTOBS in a data step.

 

http://documentation.sas.com/?docsetId=proc&docsetTarget=p08ss3c3xtt2qzn1fsma45gyz333.htm&docsetVers...

Patrick
Opal | Level 21

@MatthewKelley

If you're using SAS DI Studio then you need to define the first line to be read on the External File object as shown below.

Capture.JPG

Tom
Super User Tom
Super User

Do you mean that you want to ignore the variable names in the first row and have SAS just assign variable names?

Do you mean that your file doesn't have variable names in the first row?

Do you mean that SAS is trying the read the variable names in the first row as part of the data?

Or that you want to find the variable names in a later row?  Perhaps you are reading from some type of report that has one or more report titles before the lines of data?

MatthewKelley
Calcite | Level 5

Thank you all, I got it to read in properly.

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!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1269 views
  • 0 likes
  • 5 in conversation