I'm having so much fun! I should have quit working years ago!!
Anyway, I've encountered situations in the past where I just want to grab the rows of an input file "in bulk", and do things to them using DATA step code. For years, I've been using the following code:
data work.test_data;
infile "C:\some_file.txt" lrecl=32767;
length inrec $ 32767;
input;
inrec = _infile_;
/* and then use inrec as my source of text for further processing, using string functions or PRX functions or whatever */
run;
I like it because I consider it the bare minimum, but would any changes improve it? Are there any conditions under which it won't work?
Thanks,
Tom
Tom,
My personal preference, in such cases, is to use input @, modify _infile_ as needed, and then just use a normal input statement to re-read the modified data row.
Tom,
My personal preference, in such cases, is to use input @, modify _infile_ as needed, and then just use a normal input statement to re-read the modified data row.
NO. Your code looks good. Here is an instead way.
data work.test_data;
infile "C:\some_file.txt" length=len lrecl=32767;
input inrec $varying32676. len;
run;
Working with the RAW input record is perfectly OK and reasonable from my understanding,
but why not just use the automatic _infile_ variable and work from there?
I really don't see no need to copy it's content to a second variable, a 32K PDV is quite big in memory.
Cheers from Portugal.
Daniel Santos @ www.cgd.pt
I guess after a couple of days with no responses we can consider this closed.
Thank you all - I learned something useful from each of your answers, and will absolutely try them all out.
Please don't be offended - I was going to mark you all "Correct Answer", but I've never awarded these before and just discovered that there are limits on numbers - statistically, I consider this a poor practice 😉
So Art gets the green star for being first (and maybe for being a fellow Canuck?)
Happy Thanksgiving and Columbus Day to all of you!
Tom
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.