I'm importing files through a loop:
forvalues y=2010/2022 {
use "file`y'V1.dta"
[making changes]
save “file`y'.dta”
}
Problem is that some of the filenames have "V2" or "V3" instead of "V1".
How can I "ignore" this part? In some programming languages, you just write “*” to indicate that anything can be in that spot in the string.
I cannot change the filenames in their original directory since they are on a shared server and they are too big to just copy.
The most satisfactory solution is to loop over files
file20??V?.dtawhich you can populate in Stata. Compare my answer at https://www.statalist.org/forums/forum/general-stata-discussion/general/1705910-loading-datasets-using-a-loop-with-an-inconsistent-naming-schemeOtherwise, something like this may help. Necessarily not tested.
EDIT There are no concrete examples of directory or folder structure in your question. Nor do you state what operating system you are using. But let's suppose you are working in directory
myplacebut using files fromotherplace. Forward slashes always work in Stata in this context.