Hello,

I have 38 csvfiles that I want to merge into one DTA file using a loop (foreach) . My csvfiles are named in "2021-MM-YY.csv" format. The variable names are contained in one particular row (#Row 4) of the dataset and I want to also extract a certain range of rows (4-2940) from each csv file and bring it into the (Append ) data. I also want to extract the date out of the file name and store it in a date variable in the dataset, to be able to identify what date the particular observation is for. So far I have only been able to figure out this part of the loop to import the file, where I'm still confused about how to name the file appropriately in the path.

import delimited "files\2021-**-**.csv", delimiter(comma, collapse) varnames(4) encoding(UTF-8) rowrange(:2940) parselocale(en_IN)