Help using Base SAS procedures

Working with imported text file

Super Contributor
Posts: 405

Working with imported text file

I'm doing an infile & input statement to read in a big text file. That part I have working fine

data raw ;
infile 'c:\testtxt' TRUNCOVER;
input text $CHAR100. ; /*keep leading blanks*/
run ;

My problem is with the data in the table. This is the layout of the data:

TEST99 This is a test var


This is a test variable. Looking to see if I can import and select out parts of the file for
further research. Does this work?
(What was is this variable?)

This variable is used in many ways across this project. If you look at the test documentation you will
read how you are supposed to use this variable.

200 10-20 Test Value 1
100 30-40 Test Value 2
245 50-60 Test Value 3
126 70-80 Test Value 4
102 90-100 Test Value 5

I need to be able to take each section and put it in it's own table.
For instance I would like a table that has just 2 variables one for my range and one for
my label.
10-20 Test Value 1
30-40 Test Value 2
50-60 Test Value 3
70-80 Test Value 4
90-100 Test Value 5

Thank you for any help
Super Contributor
Super Contributor
Posts: 3,176

Re: Working with imported text file

Posted in reply to jerry898969
Yes, you can, using the SAS INPUT function in a variable/column assignment statement; also you would want to use _INFILE_ as the first argument to INPUT. Also, consider how to access each sub-field, either using SCAN, SUBSTR, FIND, or a combination of these functions.

Then, on your DATA step's first DATA step, code each of the output file(s) you want to generate, and explicitly code OUTPUT statement(s) as needed to generate multiple files.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic / post:

data step programming

data step "_infile_"

data step input function
Super Contributor
Posts: 405

Re: Working with imported text file


Thank you again for your help. The _infile_ with the input function makes sense but what i'm having a hard time with is knowing how to grab the text. I know that under this row


there are two blank rows then my data starts there and every row after that till another blank row is hit. Am I able to do that with this logic? Since I don't know what text is going to be there I can only know where it will start based on the blank rows. Does this make sense or am I making it more difficult then it needs to be.

Thanks for the help
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation