I am running into a strange problem while trying to run my code. The following is a sample of my code (Note: I am already in the main directory):
cd "C:/`mydir'" //where `mydir' is the local for the folder containing the fig folder.
use cleaned.dta, clear
local outcome drr_trtd
tempname post_handle
local postfile_varlist str12(tau_text) double(pt_est se)
postfile `post_handle' `postfile_varlist' using "fig/dta/es_M12_P11_`outcome'.dta", replace
postclose `post_handle'
use "fig/dta/es_M12_P11_`outcome'.dta", clear
The issue is that whenever I try and run this code, I get an error:
postfile `post_handle' `postfile_varlist' using "fig/dta/es_M12_P11_`outcome'.dta", replace
fig/dta/es_M12_P11_drr_trtd.dta invalid name
I assumed that this may be because of quotation marks, so I removed the quotation marks and then I get the following error:
postfile `post_handle' `postfile_varlist' using fig/dta/es_M12_P11_`outcome'.dta, replace
/ invalid name
I then tried to make the file without a file-path that is I edited the postfile command as follows:
postfile `post_handle' `postfile_varlist' using "hello.dta", replace
Now, with the quotations I get the error:
"hello.dta invalid name
Without the quotation I get the same error but with hello.dat. Am I just doing something obviously wrong here? I do not understand why I am getting this error.
New Code:
local mydir /Users/F H/Desktop/Ray/analysis
cd "C:/`mydir'/"
tempname post_handle
local postfile_varlist str12(tau_text) double(pt_est se)
pwd
postfile `post_handle' `postfile_varlist' ///
using "\fig\dta\event_study_M24_P59_sa.dta" ///
, replace
I get the error:
(note: file \fig\dta\event_study_M24_P59_sa.dta not found)
file \fig\dta\event_study_M24_P59_sa.dta could not be opened
figdirectory? Try posting a reproducible example showing your error. Something like I've posted below. (I can't reproduce it.) - Roberto Ferrerupdate. - Roberto Ferrermacro listjust before thepostfilecall. That will show you which local macros are visible. The local macrovaris not defined in your code, although that doesn't seem important here. - Nick Cox