Dear all:

I have a data set that looks roughly like this, i.e. individuals in groups. For most but not all individuals I observe a variable value, e.g. income or blood pressure or whatever helps you imagine.

Code:
// Create data set
clear
set obs 50
egen group = seq(), from(1) to(5)         // 5 groups
gen indiv = _n                            // 10 members each
generate value = round(runiform()*100, 1) // Value between 1 and 100
gen r = runiform()                        // Random variable for sorting and for
replace value = . if (inrange(r, .02, .1) | inrange(r, .8, .9)) // missing values
I now want to assign each group a group-level value which should be a random draw of value from each group:

Code:
// Choose random value as group value
bysort group (r): gen groupvalue = value[1]
But I don't want it to be a missing value! How do I do that best? My data set is huge, will have to run this many times, worried about coming up with a suboptimal solution myself that will cause me pain down the line.

Cheers
Nora