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
Ranking means from highest to lowest after bysort occupation: sumDear all, I would like to know how to rank means from highest to lowest after the following command…
xtreg fe; xtreg re; hausman; vce(robust)Hello everybody! I am running the following models: 1. xtreg DepVar IndepVar1 IndepVar2 IndepVar3,…
Adding variables with partial common namesHi, I have variables such as fac_tot30_outpatient and prof_tot30_outpatient, which I want to sum by…
Data directory in Stata webHello, To look at the datafiles that are inbuilt in Stata software we use the command "sysuse dir". …
Creating funnel plots in meta-analyses of proportion studiesHi all, Hunter et al (https://doi.org/10.1016/j.jclinepi.2014.03.003) suggested that conventional fu…
Subscribe to:
Post Comments (Atom)
0 Response to Random Selection
Post a Comment