Loop Over String and Numeric Vectors in Stata (DO, more see: Fan and Stata4Econ)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  stata_fs_loop
       log:  C:\Users\fan/Stata4Econ//prog/basics/fs_loop.smcl
  log type:  smcl
 opened on:   5 May 2020, 20:35:14


. log on $st_logname (log already on)

. . ///-- Site Link: Fan's Project Reusable Stata Codes Table of Content > di "https://fanwangecon.github.io/" https://fanwangecon.github.io/

. di "https://fanwangecon.github.io/Stata4Econ/" https://fanwangecon.github.io/Stata4Econ/

. . ///-- File Title > global filetitle "Loop Over String and Numeric Vectors in Stata"

. . /////////////////////////////////////////////////////////////////////////////// > ///--- Loop over String > /////////////////////////////////////////////////////////////////////////////// > . #delimit; delimiter now ; . global ls_svr_outcome " > el_i_mand_talk_m2a el_i_mand_talk_m2b el_i_mand_talk_m2c > el_i_mand_write_m2a el_i_mand_write_m2b el_i_mand_write_m2c > el_i_mnew_m2a el_i_mnew_m2b > el_i_nnet_m2a el_i_nnet_m2b > ";

. #delimit cr delimiter now cr . . local it_counter = 0

. foreach svr_outcome in $ls_svr_outcome { 2. local it_counter = `it_counter' + 1 3. di "`it_counter'th item of string list: `svr_outcome'" 4. } 1th item of string list: el_i_mand_talk_m2a 2th item of string list: el_i_mand_talk_m2b 3th item of string list: el_i_mand_talk_m2c 4th item of string list: el_i_mand_write_m2a 5th item of string list: el_i_mand_write_m2b 6th item of string list: el_i_mand_write_m2c 7th item of string list: el_i_mnew_m2a 8th item of string list: el_i_mnew_m2b 9th item of string list: el_i_nnet_m2a 10th item of string list: el_i_nnet_m2b

. . ///--- End Log and to HTML > log close _all name: stata_fs_loop log: C:\Users\fan/Stata4Econ//prog/basics/fs_loop.smcl log type: smcl closed on: 5 May 2020, 20:35:14 -------------------------------------------------------------------------------------------------------------------------------------------------------------------