Help using Base SAS procedures

How to import delimited text file with comment lines using PROC IMPORT?

Reply
New Contributor
Posts: 3

How to import delimited text file with comment lines using PROC IMPORT?

Hi,

Can I use PROC IMPORT to import delimited text file which contains a lots of comment lines at the beginning of the file. The comment lines are marked with "#"s. I want to exclude the comment lines and start to import at the header line.

Thanks.

sy
Super User
Posts: 10,501

Re: How to import delimited text file with comment lines using PROC IMPORT?

Single input file or multiple input files with varying numbers of comment lines?
New Contributor
Posts: 3

Re: How to import delimited text file with comment lines using PROC IMPORT?

I've resolved the problem. Thank you for your reply.
New Contributor
Posts: 3

Re: How to import delimited text file with comment lines using PROC IMPORT?

Thank you for all your replies. I've resolved the problem by using DBailey's approach, i.e., I used substr( ) to delete the lines with #s in the DATA step.
Super User
Posts: 9,682

Re: How to import delimited text file with comment lines using PROC IMPORT?

It seems that proc import cann't do it, But Import Data Wizard in sas menu can choose the start row of data. Maybe it is not what you want.


Ksharp
Super Contributor
Posts: 578

Re: How to import delimited text file with comment lines using PROC IMPORT?

You could always fall back and write your own data step to check the first character of the line before parsing and outputting the data set.
Contributor sss
Contributor
Posts: 65

Re: How to import delimited text file with comment lines using PROC IMPORT?

HI
I am not sure about the wizard but you can do by code

data dataset_name;
infile 'path\file.txt' dlm='#&*';
input var1$ var2 ;
run;
Ask a Question
Discussion stats
  • 6 replies
  • 139 views
  • 0 likes
  • 5 in conversation