Hello,
I am trying to remove all of the backslashes of a variable that are located after the last letter. Example below.
But the number of backslashes are different across observations so not sure how to set up a strpo command that is consistent across these.
The "spouse_names" variable was generated by concacenating 6 variables and indicating a "/" should separate names. If an observation did not have 6 names, which is the max number, the backslashes were still added to the end.
Thanks.
I am trying to remove all of the backslashes of a variable that are located after the last letter. Example below.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str9 hhid str99 spouse_names "00030-001" "HABSA MOUSSA BA/////" "00030-002" "SALA KA/////" "00030-003" "" "00030-004" "AISSATA DJIBY SY/////" "00030-005" "FATY Sy/////" "00030-006" "DIEYNABA DIAKHO/////" "00030-007" "DIENABA YERO KA/HABY DJIBY BA////" "00030-008" "FATY YERO BA/////" "00030-009" "HAWA SAMBA BA/////" "00030-010" "" "00030-011" "" "00030-012" "Salamata Dem/////" "00030-013" "Hawa Thiogo/////" "00030-014" "" "00030-015" "Aissata Ba/////" "00030-016" "Thioya Diallo/////" "00030-017" "Habsa Demba Kebe/////" "00030-018" "Maimouna Diallo/////" "00030-019" "Salamata Ba/////" "00030-020" "Gueda Diallo/////" "00030-021" "" "00030-022" "Hawa Sy/////" "00030-023" "Houleye Soumare/////" "00030-024" "Fama Ba/////" "00030-025" "" "00030-026" "" "00030-027" "Kadia DIALLO/////" "00030-028" "Rougui Abou Sy/////" "00030-029" "" "00030-030" "Dieynaba DIALLO/////" "00030-031" "Aïssata Ardo DIALLO/////" "00030-032" "Ramata Awe/////" "00030-033" "Hawa Aw/////" "00030-034" "Bolo Sow/////" "00030-035" "Dieynaba Ka/Salamata Sow////" "00030-036" "Hawa Tamboura/////" "00030-037" "Bolo Ba/////" "00030-038" "Farmata Thioye/////" "00030-039" "Houleye Diallo/Ramata Ba////" "00030-040" "Haby Ba/////" "00030-041" "Dieynaba issaka Ba/////" "00030-042" "DIARIATA AW/////" "00030-043" "KARDIATOU PATHE DIALLO/////" "00030-044" "" "00030-045" "HABY DEMBA DIOUM/////" "00030-047" "RAMATOULAYE DIOUM/////" end
The "spouse_names" variable was generated by concacenating 6 variables and indicating a "/" should separate names. If an observation did not have 6 names, which is the max number, the backslashes were still added to the end.
Thanks.
Comment