View Full Version : SAS question: Multiple infiles
02-04-2003, 12:34 PM
I have one data step, that I want to run for about 15 different flat files. Anyone know a way to do this without without having to copy the data step 15 times and changing just the one line?
Not to be facetious . . . use a do loop.
I don't recall the sytax, but SAS supports these.
02-04-2003, 01:06 PM
Should be able to set up a macro to do that. Pass the input file as your parameter. I've not worked with macros much but I inherited a bunch of jobs that use them. Basically your have 15 lines in your data step with your 15 file names and then a macro subprogram that will make this change for you. Good luck
I agree with GadgetGeek regarding macro syntax.
This is what I used to solve a similar looping problem - that produced similar head-banging frustration.
02-07-2003, 12:14 PM
02-07-2003, 01:22 PM
If you're putting the files together, then an infile statement would do the trick.
If you want to process the files one at a time and keep them separate, then an itsy macro would solve your issue.
04-18-2003, 05:15 PM
If it is not important to you to identify which data lines belong in which files (you care only about the summary data, perhaps). If you are using a mainframe, you can always concatenate them in JCL. In the data step you could also do something like
INFILE F1 END=DONE1
F2 END=DONE2 /* etc */
Then you have boolean variables DONE1,...DONEn to know when you are about to start a new file.
You can also use the filevar= option to read in a list of files, then input from those file locations. I have never done this, so I will not attempt to elaborate. However, details may be found in the SAS Language Reference - "Reading from Multiple Input Files"
vBulletin® v3.7.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.