Hi,
I am trying to load the data from multiple text files palced in a folder having the same structure to one file. All the text files are having the same headers.
Sample data in one of the file:
Product Customer Qtr 1 Qtr 2 Qtr 3 Qtr 4
Alice_Mutton ANTON 28080 70200 110400 55125
Aniseed_Syrup BERGS 31200 78000 60000 14700
Boston_Crab BOLID 28080 6000 77280 117000
Escargots_Bourgogne BOTTM 117000 20000 16560 122360
Filo_Mix ERNSH 112320 18000 92000 260715
Geitost GODOS 6240 28080 24840 41952
Also the names of the file are cust101, cust102, cust103.........Cust200...
Can anyone please suggest an efficient way to read the data from all these text file in to a single file.
Regards,
Saket
Here's my recommended solution:
1. You need your input/informat/format statement for reading a single file.
2. In the code in link above, change the path, and use a wildcard to reference the data.
3. Make sure to use the EOV= variable to avoid reading the header in each file.
You can read multiple files using wildcrds. The code below is not tested but should help get you started.
%let data_filepath = c:\...\cust*; * modify path as appropriate for your system;
data temp;
infile firstobs=2 "&data_filepath";
input product $ customer $ qtr1-qtr4;
run;
Here's my recommended solution:
1. You need your input/informat/format statement for reading a single file.
2. In the code in link above, change the path, and use a wildcard to reference the data.
3. Make sure to use the EOV= variable to avoid reading the header in each file.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.