To input multiple raw data files into SAS, you can use the filename statement. For example, suppose that we have four raw data files containing the sales information for a small company, one file for each quarter of a year. Each file has the same variables, and these variables are in the same order in each raw data set. On the filename statement, we would first provide a name for the files, in this example, we used the name year. Next, in parentheses, we list each of the data files to be included. You can list as many files as you like on the filename statement. In the data step, we use the infile statement and give the name of the files that we used on the filename statement. We use the input statement to list the names of the variables.
First, let’s see what the raw data files look like.
quarter1.dat
1 120321 1236 154669 211326 1 326264 1326 163354 312665 1 420698 1327 142336 422685 1 211368 1236 156327 655237 1 378596 1429 145678 366578quarter2.dat
2 140362 1436 114641 362415 2 157956 1327 124869 345215 2 215547 1472 165578 412567 2 204782 1495 150479 364474 2 232571 1345 135467 332567quarter3.dat
3 140357 1339 142693 205881 3 149964 1420 152367 223795 3 159852 1479 160001 254874 3 139957 1527 163567 263088 3 150047 1602 175561 277552quarter4.dat
4 479574 1367 155997 36134 4 496207 1459 140396 35941 4 501156 1598 135489 39640 4 532982 1601 143269 38695 4 563222 1625 147889 39556filename year ('d:quarter1.dat' 'd:quarter2.dat' 'd:quarter3.dat' 'd:quarter4.dat'); data temp; infile year; input quarter sales tax expenses payroll; run; proc print data = temp; run;Obs quarter sales tax expenses payroll 1 1 120321 1236 154669 211326 2 1 326264 1326 163354 312665 3 1 420698 1327 142336 422685 4 1 211368 1236 156327 655237 5 1 378596 1429 145678 366578 6 2 140362 1436 114641 362415 7 2 157956 1327 124869 345215 8 2 215547 1472 165578 412567 9 2 204782 1495 150479 364474 10 2 232571 1345 135467 332567 11 3 140357 1339 142693 205881 12 3 149964 1420 152367 223795 13 3 159852 1479 160001 254874 14 3 139957 1527 163567 263088 15 3 150047 1602 175561 277552 16 4 479574 1367 155997 36134 17 4 496207 1459 140396 35941 18 4 501156 1598 135489 39640 19 4 532982 1601 143269 38695 20 4 563222 1625 147889 39556