BookmarkSubscribeRSS Feed
jerry898969
Pyrite | Level 9
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


def: NUM WIDTH:5 DECIMALS:5


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
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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 site:sas.com

data step "_infile_" site:sas.com

data step input function site:sas.com
jerry898969
Pyrite | Level 9
Scott,

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

"def: NUM WIDTH:5 DECIMALS:5"

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1272 views
  • 0 likes
  • 2 in conversation