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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: