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

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 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
  • 1254 views
  • 0 likes
  • 5 in conversation