Monday, July 1, 2019

Assigning numbers from 1 to (total number of observations) randomly to the data set

Hello,
What is the best way to assign a random number from 1 to 413,294 (which is the total number of observations) to a data set? Excerpt below:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str11 gender str5(category ch1)
"Male"   "Other" ""    
"Female" "Other" ""    
"Male"   "Other" ""    
"Male"   "Other" ""    
"Female" "Other" ""    
"Female" "Other" ""    
"Female" "ST"    "561" 
"Male"   "SC"    ""    
"Male"   "ST"    ""    
"Female" "ST"    ""    
"Male"   "ST"    ""    
"Female" "Other" ""    
"Male"   "SC"    ""    
"Male"   "ST"    ""    
"Male"   "Other" ""    
"Male"   "Other" ""    
"Female" "Other" ""    
"Male"   "SC"    ""    
"Female" "Other" ""    
"Male"   "ST"    ""    
"Male"   "Other" ""    
"Male"   "ST"    ""    
"Male"   "Other" ""    
"Male"   "ST"    ""    
"Male"   "Other" ""    
"Female" "Other" ""    
"Female" "Other" "2273"
"Male"   "SC"    ""    
"Female" "Other" ""    
"Female" "SC"    ""    
"Female" "SC"    ""    
"Female" "SC"    ""    
"Male"   "Other" "739" 
"Male"   "Other" ""    
"Female" "Other" ""    
"Male"   "Other" ""    
"Female" "ST"    ""    
"Male"   "Other" ""    
"Male"   "Other" ""    
"Male"   "Other" ""    
"Male"   "Other" ""    
"Female" "ST"    "898" 
"Male"   "SC"    ""    
"Male"   "Other" "903" 
"Male"   "SC"    ""    
"Male"   "Other" "352" 
"Male"   "Other" "236" 
"Male"   "Other" ""    
"Female" "ST"    ""    
"Female" "ST"    "600" 
"Female" "ST"    "600" 
"Male"   "Other" "354" 
"Male"   "Other" ""    
"Female" "ST"    ""    
"Male"   "ST"    "124" 
"Female" "Other" ""    
"Male"   "Other" ""    
"Male"   "SC"    "1630"
"Male"   "Other" ""    
"Female" "Other" "353" 
"Male"   "Other" "737" 
"Male"   "Other" ""    
"Male"   "Other" ""    
"Male"   "Other" ""    
"Male"   "Other" ""    
"Female" "Other" ""    
"Male"   "Other" ""    
"Female" "SC"    ""    
"Male"   "Other" ""    
"Male"   "SC"    ""    
"Male"   "SC"    ""    
"Male"   "Other" ""    
"Male"   "Other" "811" 
"Female" "SC"    ""    
"Female" "SC"    "645" 
"Female" "SC"    ""    
"Male"   "ST"    ""    
"Female" "Other" ""    
"Female" "Other" "469" 
"Male"   "SC"    "467" 
"Female" "Other" ""    
"Male"   "Other" "734" 
"Female" "SC"    ""    
"Male"   "Other" "412" 
"Male"   "Other" ""    
"Female" "Other" ""    
"Male"   "SC"    ""    
"Female" "Other" ""    
"Male"   "ST"    ""    
"Male"   "Other" ""    
"Male"   "SC"    ""    
"Female" "Other" ""    
"Female" "Other" ""    
"Male"   "Other" ""    
"Male"   "ST"    "504" 
"Female" "SC"    ""    
"Male"   "Other" ""    
"Female" "ST"    ""    
"Female" "ST"    ""    
"Female" "ST"    ""    
end

No comments:

Post a Comment