Hi all-
I am having issues running a loop to import .csv files. (I have many files to import, I just include one file below for simplicity.)
The following code works successfully on STATA15:
clear all
insheet using "C:\Users\Jen\Documents\Research\CorporateBoards_n ew\Raw_data\Staticdata\deadbd1.csv"
However, when I update it to a loop (code below), it does not work:
clear all
foreach file in deadbd1 {
insheet using "C:\Users\Jen\Documents\Research\CorporateBoards_n ew\Raw_data\Staticdata\`file'.csv"
}
It gives me the following error:
file
C:\Users\Jen\Documents\Research\CorporateBoards_ne w\Raw_data\Static
> data`file'.csv not found
r(601);
I just moved all my stata-related files over from my old macbook to my new windows pc (and updated the working directory paths, etc.). This is the first code that I am attempting to run on the new windows computer, and it is not working. I am very confused because this is a super simple code that has worked for me many times on my old macbook. Has anyone else run into this issue when migrating from mac to pc?
Thanks for your help.
I am having issues running a loop to import .csv files. (I have many files to import, I just include one file below for simplicity.)
The following code works successfully on STATA15:
clear all
insheet using "C:\Users\Jen\Documents\Research\CorporateBoards_n ew\Raw_data\Staticdata\deadbd1.csv"
However, when I update it to a loop (code below), it does not work:
clear all
foreach file in deadbd1 {
insheet using "C:\Users\Jen\Documents\Research\CorporateBoards_n ew\Raw_data\Staticdata\`file'.csv"
}
It gives me the following error:
file
C:\Users\Jen\Documents\Research\CorporateBoards_ne w\Raw_data\Static
> data`file'.csv not found
r(601);
I just moved all my stata-related files over from my old macbook to my new windows pc (and updated the working directory paths, etc.). This is the first code that I am attempting to run on the new windows computer, and it is not working. I am very confused because this is a super simple code that has worked for me many times on my old macbook. Has anyone else run into this issue when migrating from mac to pc?
Thanks for your help.
Comment