Hi,
This is my first question on Statalist in all the years (10+) I have been using Stata so thanks for all of your contributions!
Issue: My .do file does not execute (e.g., producing a log file and saving new data) when I click "Do" (produces no output in the Results window). However, individual parts of the .do file execute when I select and "Do Selection" only (it runs, and stops with any errors). I have cleared all data, reopened Stata and opened the .do file expecting it to change the working directory, import or use saved data, and execute the commands, resulting in a .log file, and saved data in my working directory, but executing the .do file only produces lines of code preceded by '>' in the Results window, and no .log file or new data.
I am using version 17 of StataBE. I have created multiple .do files that start with a similar structure (see below) and include hundreds of lines of data cleaning commands (e.g., foreach loops, rename, label, tab, describe, etc.) but no regression commands or anything with estimations.
Any assistance (other than suggestions to upgrade to Stata 18 🙂) is appreciated. Thank you!
.do file content example snippet:
******/*/*/*/***Program Name: Data Clean PSES Teacher Survey 2022-23 ******/*/*/*/***
******/*/*/*/***Author: C. JACKSON******/*/*/*/***
**//uses the PSES_Teacher Open Data Survey for 2022-2023 retrieveed from SDP Open Data in March 2024********************************************** *******
version 17.0
clear all
capture log close
set linesize 80
set more off
set varabbrev off
display "$S_DATE"
*setting up directory and log
cd "PATH/Analysis Data"
log using "PSES_TeacherSurveyCleaning.log", replace
*Importing 2022-2023 PSES Teacher survey open data file--by school survey responses
import excel "PSES_Teacher_Open-Data_2022-2023.xlsx", sheet("by School") firstrow case(lower) allstring clear
browse foreach var of varlist _all {
cap assert `var'[4] == "Percent"if !_rc drop `var'
}foreach var of varlist a-g {
loc name = strlower(strtoname(`var'[4]))
cap rename `var' `name'
loc lbl = `name'[4]
la var `name' "`lbl'"
}
rename ulcs ulcscode
save "PSES_Teacher_Survey_2022_2023.dta", replace
foreach var of varlist q3a-df {
loc lbl = `var'[2]
la var `var' "How often - `lbl'"
loc name = strlower(strtoname(`var'[3]))
rename `var' `var'_`name'
}
*q3a
rename j_rarely q3a_rarely
rename l_occasionally q3a_occasionally
rename n_most_or_all_of_the_time q3a_most_all
save "clean_PSES_Teacher_Survey_2022_2023.dta", replace
log close
Data Example (Dataex) below:
Thanks!
This is my first question on Statalist in all the years (10+) I have been using Stata so thanks for all of your contributions!
Issue: My .do file does not execute (e.g., producing a log file and saving new data) when I click "Do" (produces no output in the Results window). However, individual parts of the .do file execute when I select and "Do Selection" only (it runs, and stops with any errors). I have cleared all data, reopened Stata and opened the .do file expecting it to change the working directory, import or use saved data, and execute the commands, resulting in a .log file, and saved data in my working directory, but executing the .do file only produces lines of code preceded by '>' in the Results window, and no .log file or new data.
I am using version 17 of StataBE. I have created multiple .do files that start with a similar structure (see below) and include hundreds of lines of data cleaning commands (e.g., foreach loops, rename, label, tab, describe, etc.) but no regression commands or anything with estimations.
Any assistance (other than suggestions to upgrade to Stata 18 🙂) is appreciated. Thank you!
.do file content example snippet:
******/*/*/*/***Program Name: Data Clean PSES Teacher Survey 2022-23 ******/*/*/*/***
******/*/*/*/***Author: C. JACKSON******/*/*/*/***
**//uses the PSES_Teacher Open Data Survey for 2022-2023 retrieveed from SDP Open Data in March 2024********************************************** *******
version 17.0
clear all
capture log close
set linesize 80
set more off
set varabbrev off
display "$S_DATE"
*setting up directory and log
cd "PATH/Analysis Data"
log using "PSES_TeacherSurveyCleaning.log", replace
*Importing 2022-2023 PSES Teacher survey open data file--by school survey responses
import excel "PSES_Teacher_Open-Data_2022-2023.xlsx", sheet("by School") firstrow case(lower) allstring clear
browse foreach var of varlist _all {
cap assert `var'[4] == "Percent"if !_rc drop `var'
}foreach var of varlist a-g {
loc name = strlower(strtoname(`var'[4]))
cap rename `var' `name'
loc lbl = `name'[4]
la var `name' "`lbl'"
}
rename ulcs ulcscode
save "PSES_Teacher_Survey_2022_2023.dta", replace
foreach var of varlist q3a-df {
loc lbl = `var'[2]
la var `var' "How often - `lbl'"
loc name = strlower(strtoname(`var'[3]))
rename `var' `var'_`name'
}
*q3a
rename j_rarely q3a_rarely
rename l_occasionally q3a_occasionally
rename n_most_or_all_of_the_time q3a_most_all
save "clean_PSES_Teacher_Survey_2022_2023.dta", replace
log close
Data Example (Dataex) below:
[CODE] | ||||
* Example generated by -dataex-. For more info, type help dataex | ||||
clear | ||||
input str4 ulcscode str74 school_name str16 learning_network str11 | sector | str14 | response_count str17 response_rate | str13 met_threshold |
"" "" | "" "" | "" "" | "" | |
"" "" | "" "" | "" "" | "" | |
"" "" | "" "" | "" "" | "" | |
"ULCS" "School Name" | "Learning Network" "Sector" | "Response Count" "Response Rate" | "Met Threshold" | |
"1010" "Bartram, John High School" | "Network 13" "District" | "8" ".25" | "Yes" | |
"1020" "West Philadelphia High School" | "Network 13" "District" | "4" ".0952380952380952" | "No" | |
"1030" "High School of the Future" | "Innovation" "District" | "25" ".581395348837209" | "Yes" | |
" |
Comment