Hello,
I have an extraction issue in Stata.
I want to extract a specific cell from Stata data based on the value of another variable. Conceptually, I need for Stata to read down a column of data, and I need it to continue to read the column of data while it is decreasing. When the data in the column increases, I need Stata to select data in a cell from another variable.
To clarify, here is what I need Stata to do in three steps. Step 1, I need Stata to read the data in variable "sco". Step 2, when Stata reaches data point 153 in sco, I need it to select number 3 in the group variable. Step 3, put the number 3 in the group variable in a local variable to be used elsewhere. I hope it is obvious, but I need the syntax to have the flexibility to be any number, as this is just an example. Does anyone have any idea how to do this?
To clarify, here is what I need Stata to do in three steps. Step 1, I need Stata to read the data in variable "sco". Step 2, when Stata reaches data point 153 in sco, I need it to select number 3 in the group variable. Step 3, put the number 3 in the group variable in a local variable to be used elsewhere. I hope it is obvious, but I need the syntax to have the flexibility to be any number, as this is just an example. Does anyone have any idea how to do this?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(sco female group) 147 1 1 108 0 1 18 0 3 153 0 1 50 0 2 51 1 2 102 0 1 57 1 1 160 1 1 136 0 1 end
Thank you in advance.
0 Response to Cell Extraction and reading data
Post a Comment