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
Panel data regression - several dummy variables or xtreg, with more than fixed-effect variableHello, I'm trying to work out the advantages/disadvantages of using xtreg with a panel dataset, or u…
seemingly unrelated regressionHello every one I have a problem with SUER model i ran these commands HTML Code: logistic Fraud …
Generate distinct id for dyads in groups in long formatDear Statalist. I have a dataset of dyads in groups in long format. I need to generate a variable "…
Sargan test (overidentifying restrictions)Hi every one I have an inquiry about why I sometimes get Sargan score and Bessnman and Sometimes onl…
How to add names to points on a spatial graph using spmap.Dear all, I have managed to plot the spatial boundaries on the map and the locations of different p…
Subscribe to:
Post Comments (Atom)
0 Response to Random Selection
Post a Comment