Hello, I want to create a unique random integer.
I have 34 observations and I wish to have for each observation a number between 1 and 34 which is not identical to the observation
Here is my code: With this code, no data is modified in the table
gen expert= runiformint(1, 34)
bysort expert: gen doublon=_n
while doublon!=1 | a==expert{
replace expert= runiformint(1, 34)
drop doublon
bysort expert: gen doublon=_n }
Example: I don't want the errors in lines 4 and 5
I have 34 observations and I wish to have for each observation a number between 1 and 34 which is not identical to the observation
Here is my code: With this code, no data is modified in the table
gen expert= runiformint(1, 34)
bysort expert: gen doublon=_n
while doublon!=1 | a==expert{
replace expert= runiformint(1, 34)
drop doublon
bysort expert: gen doublon=_n }
Example: I don't want the errors in lines 4 and 5
a | expert | doublon |
1 | 11 | 1 |
2 | 6 | 1 |
3 | 15 | 1 |
4 | 15 | 2 |
5 | 5 | 1 |
Comment