I have interviewed heads of households and asked their fathers' names. In some cases the father is alive and has also been interviewed. In some cases he is not. I need to identify whether the father of a certain interviewee has also been interviewed.
I would need something like:
gen Father_Interviewed=find("Father") into name
For instance: find("Metlick Elly") into name.
I know that I could use the command strpos to identify whether a specific string is included in a string variable:
gen Father_MetlickElly_Interviewed = strpos(name,"Metlick Elly")
But I need a function that inputs the father's name automatically.
Thank you very much!
(Incidentally, in the above use of strpos, for some unexplicable reasons the new var is generated only for some names of the new variables but not others).
gianluca
+------------------------------------+
| name Father |
|------------------------------------|
14. | Kepas Metlick Metlick Elly |
36. | Daniel Raoh SAM JARAH |
40. | Metlick Elly Old Elly |
67. | Torohin Pilus THOMAS HAMUN BAREA |
72. | Joseph Raoh Daniel Raoh |
|------------------------------------|
73. | Philimon Hona Daniel Raoh |
74. | Wilfred Hotei Daniel Raoh |
75. | Biloli Raoh Daniel Raoh |
76. | Goldie Ragu Daniel Raoh |
92. | Simon Torohin Torohin Pilus |
+------------------------------------+
.
Related Posts with Searching for variable string content into another string variable
Moving average between missing variablesHi. I have monitoring data which were collected every three hours, as shown below. I am trying to fi…
Loop to replace string variablesMy dataset is in wide format. Variables are string and non-string. Lots of vaibales contain "NA". I …
How to create two new variables from one?Dear statalists, I'm writing my master thesis and have come across some data handling-issues. I use…
Kernel RegressionI am trying to apply kernel regression to detect technical patterns in stock market prices. Attached…
How to break the interval value (e.g. 1200-1347) of a string variable into many years taking values from 1200 to 1347 year by year?Is the question clear? Many thanks! Linghui Han …
Subscribe to:
Post Comments (Atom)
0 Response to Searching for variable string content into another string variable
Post a Comment