I am working with a dataset containing both private and government school data, where the variables in each dataset have identical names. I am attempting to merge the two datasets, but the identical variable names are causing issues during the merging process. To resolve this, I would like to add a prefix (e.g., 'pvt') to all the variables in the private school dataset prior to merging. Although I have consulted the Stata guide (https://www.stata.com/manuals/drenamegroup.pdf), I have been unable to achieve the desired outcome. I would appreciate any suggestions or guidance you may have.
Gove School
------------------ copy up to and including the previous line ------------------
private school
----------------------- copy starting from the next line -----------------------
"VlgCode` is the merging ID, but I would like to change all variable names before merging. For the government school data, I would like to add either the prefix or suffix 'gov', and for the private school data, I would use 'pvt'.
Gove School
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str5 VlgCode int SID byte(STYPE S006 S00) str16 S00a "10" 4422 2 . 3 "1 to 10" "19" 4423 2 . 4 "" "20" 4424 2 . 2 "" "1" 4425 2 . 2 "" "9" 4426 2 . 1 "" end
private school
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str5 VlgCode int SID byte(STYPE S006 S00) str16 S00a "10" 1 1 . 4 "N TO 5" "19" 2 1 . 3 "" "20" 3 1 . 3 "" "1" 4 1 . 1 "" "9" 5 1 . 2 "" end

Comment