dear all,
I have to infile a text file like the one following.
At the moment I just need to have a dataset with one variable and one record for each row of the text file. So that following I can extract something from it (for instance I need all the codes following @I01)
I am not good with infile and input and my attempts have failed. I also tried to transform into excel and the import it into sas but without success.
any help is appreciated
thank you in advance
:R: John Smith, 999-7543,John.Smith@gmail.com
:I:
//Q XYZRTSWPQ NSPRQLQ
//N L 01WOW13
@T
!BRR 08;LIM 20
@01@?30@02
!BRR -100;LIM 0
!LIM 68;BRR 2
@03
@A
Dear
CompanyName
Street Name
Town Name County Post Code
@I01100100100
@I02robqqgzr
@I03100100100
@A
Dear
CompanyNAme
Street Name
Town Name County PostCode
@I01200200200
@I02robfxmal
@I03200200200
@A
Since the outcome of the program is not exactly clear, I made one up myself, but it might give you a hint on the techniques to use.
With the trailing @ sign in the INPUT statement you can read a line from the file and keep it in the input buffer, so the next INPUT statement will read from the same input buffer.
I made up two record types, on that determines the beginning of a block of lines and one that ends the block of lines to read.
Have a look, it might help you to get started with what you need.
Since the outcome of the program is not exactly clear, I made one up myself, but it might give you a hint on the techniques to use.
With the trailing @ sign in the INPUT statement you can read a line from the file and keep it in the input buffer, so the next INPUT statement will read from the same input buffer.
I made up two record types, on that determines the beginning of a block of lines and one that ends the block of lines to read.
Have a look, it might help you to get started with what you need.
Thank you very much Bruno. It's perfect for what I need. Just I do not understand the use of the second @ in the first input statement.
The first @ in the input statement positions the cursor at column 1;
The second, trailing(!) @ tells SAS to keep the contents of the input buffer and not read a new line.
The input statement without the trailing @ switches to the next line of the infile after reading
If at first you just want to make sure that you read everything that's in a line, try the following:
%let maxrl=500; * or any number that is appropriate;
data infile1;
infile"xxxx" lrecl=&maxrl truncover;
input whole_line $&maxrl.;
run;
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.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.