Hello,
I need help replacing the variable "campus_grounds" with the "school_name" of the observation that contains "Yes" for in the "main_campus" variable. I want to do this for all observations that share the same psal_code. I tried
bysort psalcode: gen psal_grounds=school_name if main_campus=="Yes" , but this only applies the change to the observation that contains "yes". Below is a sample of my data set and the outcome I want to achieve:
clear
input int psalcode str50 school_name str3 main_campus float campus_grounds
3515 "Frank McCourt High School" "" .
3515 "Innovation Diploma Plus" "" .
3515 "The Urban Assembly School for Green Careers" "" .
3515 "The Global Learning Collaborative" "Yes" .
10526 "Marble Hill High School for International Studies" "" .
10526 "Bronx Engineering and Technology Academy" "" .
10526 "Bronx Theatre High School" "" .
10526 "New Visions Charter High School for the Humanities" "Yes" .
10526 "Bronx School of Law and Finance" "" .
10526 "English Language Learners and International Suppor" "" .
10526 "New Visions Charter High School for Advanced Math" "" .
end
[/CODE]
I would like to see:
clear
input int psalcode str50 school_name str3 main_campus float campus_grounds
3515 "Frank McCourt High School" "" "The Global Learning Collaborative"
3515 "Innovation Diploma Plus" "" "The Global Learning Collaborative"
3515 "The Urban Assembly School for Green Careers" "" "The Global Learning Collaborative"
3515 "The Global Learning Collaborative" "Yes" "The Global Learning Collaborative"
10526 "Marble Hill High School for International Studies" "" "New Visions Charter High School for the Humanities"
10526 "Bronx Engineering and Technology Academy" "" "New Visions Charter High School for the Humanities"
10526 "Bronx Theatre High School" "" "New Visions Charter High School for the Humanities"
10526 "New Visions Charter High School for the Humanities" "Yes" "New Visions Charter High School for the Humanities"
10526 "Bronx School of Law and Finance" "" "New Visions Charter High School for the Humanities"
10526 "English Language Learners and International Suppor" "" "New Visions Charter High School for the Humanities"
10526 "New Visions Charter High School for Advanced Math" "" "New Visions Charter High School for the Humanities"
end
[/CODE]
I appreciate your input in helping me figure this out. Thank you!
I need help replacing the variable "campus_grounds" with the "school_name" of the observation that contains "Yes" for in the "main_campus" variable. I want to do this for all observations that share the same psal_code. I tried
bysort psalcode: gen psal_grounds=school_name if main_campus=="Yes" , but this only applies the change to the observation that contains "yes". Below is a sample of my data set and the outcome I want to achieve:
clear
input int psalcode str50 school_name str3 main_campus float campus_grounds
3515 "Frank McCourt High School" "" .
3515 "Innovation Diploma Plus" "" .
3515 "The Urban Assembly School for Green Careers" "" .
3515 "The Global Learning Collaborative" "Yes" .
10526 "Marble Hill High School for International Studies" "" .
10526 "Bronx Engineering and Technology Academy" "" .
10526 "Bronx Theatre High School" "" .
10526 "New Visions Charter High School for the Humanities" "Yes" .
10526 "Bronx School of Law and Finance" "" .
10526 "English Language Learners and International Suppor" "" .
10526 "New Visions Charter High School for Advanced Math" "" .
end
[/CODE]
I would like to see:
clear
input int psalcode str50 school_name str3 main_campus float campus_grounds
3515 "Frank McCourt High School" "" "The Global Learning Collaborative"
3515 "Innovation Diploma Plus" "" "The Global Learning Collaborative"
3515 "The Urban Assembly School for Green Careers" "" "The Global Learning Collaborative"
3515 "The Global Learning Collaborative" "Yes" "The Global Learning Collaborative"
10526 "Marble Hill High School for International Studies" "" "New Visions Charter High School for the Humanities"
10526 "Bronx Engineering and Technology Academy" "" "New Visions Charter High School for the Humanities"
10526 "Bronx Theatre High School" "" "New Visions Charter High School for the Humanities"
10526 "New Visions Charter High School for the Humanities" "Yes" "New Visions Charter High School for the Humanities"
10526 "Bronx School of Law and Finance" "" "New Visions Charter High School for the Humanities"
10526 "English Language Learners and International Suppor" "" "New Visions Charter High School for the Humanities"
10526 "New Visions Charter High School for Advanced Math" "" "New Visions Charter High School for the Humanities"
end
[/CODE]
I appreciate your input in helping me figure this out. Thank you!
Comment