Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rename variables to remove part of the text

    Dear Statalists,

    I have the following variables and would like to rename them to remove untitled### from the name. Please help me do this.

    untitled108set_number untitled108quest_number untitled108village untitled108house_number untitled108interviewer untitled108int_date untitled108supervisor untitled108time_begin untitled2hh_electricity untitled2hh_solar untitled2hh_radio untitled2hh_television untitled2hh_sofa untitled2hh_cupboard untitled2hh_phone untitled2hh_mobile untitled2hh_computer untitled2hh_table untitled2hh_clock untitled19literacy untitled19marital_status untitled19num_preg untitled19num_livebirth untitled20child_sex untitled20child_dob untitled20child_age grp_vacccarduntitled126bcg_dat grp_vacccarduntitled126bcg_nod grp_vacccarduntitled127polio_d grp_vacccarduntitled127polio_n grp_vacccarduntitled128polio1_ bf grp_vacccarduntitled129polio2_ bi grp_vacccarduntitled130polio3_ bl grp_vacccarduntitled131dpt1_da grp_vacccarduntitled131dpt1_no grp_vacccarduntitled132dpt2_da grp_vacccarduntitled132dpt2_no grp_vacccarduntitled133dpt3_da grp_vacccarduntitled133dpt3_no grp_vacccarduntitled134measles bx grp_vacccarduntitled135yfever_ ca grp_vacccarduntitled136vita_da grp_vacccarduntitled136vita_no grp_vacccarduntitled137pcoccal cg grp_vacccarduntitled138rota_da grp_vacccarduntitled138rota_no untitled118chvact_homevisit untitled118chvact_mchcounsel untitled118chvact_refillness untitled118chvact_refanc untitled118chvact_refdel untitled118chvact_refpnc untitled118chvact_bf untitled118chvact_measure untitled118chvact_other untitled105untitled123chvhome_

    Regards,
    Christian

  • #2
    You'll want to take a look at "help rename group"
    Try something like:

    Code:
    rename untitled108* *
    rename untitled20* *
    rename untitled19* *
    rename untitled2hh_* hh_*   // this could be shortened to "rename untitled2* *" once you've done "rename untitled20* *"
    rename grp_vacccarduntitled* grp_vacccard_*
    rename grp_vacccard_* gv_*  // this just shortens vars from prior line even more
    * If you get errors, for your data I would think it's because the rename will create variables that begin with numbers, and Stata doesn't allow that
    Last edited by David Benson; 28 Feb 2019, 23:44.

    Comment

    Working...
    X