Hi all,
I have a question regarding random selection.
I want to create a new variable Z, which is chosen from the existing variable C. The condition is that the range for the selection of A is with the same D variable. However, the C variable is dummy 0 and 1.
For example, the data is:
ID A B C D
1 0 0.1 0 1
2 9 0.3 0 3
3 8 0.4 1 2
4 10 0.6 1 2
5 10 0.8 0 1
6 8 0.3 1 1
7 10 0.3 0 3
8 6 0.5 1 3
For ID=1, Z variable will be selected from the same D variable, which is from ID=5 or ID=6. Therefore, either the C value of the 5th or 6th observation will be the final value for the Z variable. The selection is totally random.
Please help me out of the Stata codes.
Thanks in advance
Related Posts with Random Selection
How to produce 6-way tabulate with only percentages?Dear statalisters, I have the following data structure. Code: * Example generated by -dataex-. To…
Referring to year_t-1 to construct in- and outmigration ratesDear all, I am currently working with a survey dataset that follows people over time and looks as f…
Calculate ratio by dateDear All, I'm trying to compute a ratio based on a date (def_date) in the dataset. I try to give a …
How do I insert two weights in one tabulate command?Hi Statalist, I have a survey with two sample populations. One is representative of the general pop…
Identifying and keeping the three highest-paid waitressesHi, I would like to identify the three highest-paid waitresses in terms of "total compensation" in e…
Subscribe to:
Post Comments (Atom)
0 Response to Random Selection
Post a Comment