BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TomKari
Onyx | Level 15

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

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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.

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

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.

Ksharp
Super User

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;

DanielSantos
Barite | Level 11

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

TomKari
Onyx | Level 15

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1613 views
  • 6 likes
  • 4 in conversation