I have many files in a folder and would like STATA to read in a subset of them.
All files are .txt files. They have the following naming convention:
date_formtype_identifier_someothervariable.txt
I only want to read in if the formtype is type 1, type 2 or type 3. I do not want to read in any other type.
For example: I would like to read in these files
20160101_type1_75_89.txt
20151231_type3_89_00.txt
But not these:
20140715_type7_65_52.txt
20130223_type5_32_07.txt
I am not sure how to tell the loop to only consider type1, type2, type3?
Thanks in advance.
All files are .txt files. They have the following naming convention:
date_formtype_identifier_someothervariable.txt
I only want to read in if the formtype is type 1, type 2 or type 3. I do not want to read in any other type.
For example: I would like to read in these files
20160101_type1_75_89.txt
20151231_type3_89_00.txt
But not these:
20140715_type7_65_52.txt
20130223_type5_32_07.txt
I am not sure how to tell the loop to only consider type1, type2, type3?
Code:
cd "E:\dir" set more off local myfilelist : dir . files "*.txt" quietly foreach `x' in local type1 type2 typ3 myfilelist { import delimited using *_`x'_*_.txt
Comment