Hi All,
I am trying to make this as a program. Any help? Below is my code. Thanks

clear
set seed 123456
set obs 1000

gen auction_id = _n
local bidder = 10


foreach i of numlist 1/`bidder'{
gen bidder`i'= runiform()
}


reshape long bidder,i(auction_id) j(var)
sort auction_id bidder
by auction_id: gen nv=_n
drop var
reshape wide bidder, i(auction_id) j(nv)



quietly summarize bidder9,detail
di r(p25)
di r(p75)
tempname IQR
scalar `IQR'= r(p75)-r(p25)

egen sd=sd( bidder9)
tempname sd h
scalar `sd' = sd
di min(`sd', `IQR'/1.349)*1.06
scalar `h' = min(`sd', `IQR'/1.349)*1.06
kdensity bidder9, kernel(gaussian) bwidth(.12234464) gen(wpdf) at (bidder9)
cumul(bidder9), gen(wcdf)



local line_size `c(linesize)'
set linesize 80


clear mata
mata:
mata set matastrict on

void function createG() {

// Add G to the Stata dataset
(void) st_addvar("double", "G")

// "I have a big dataset with 1000rows, 9colums", so use a view
real matrix View
pragma unset View
st_view(View, ., ("G", "wcdf"))

// Do the arithmetic: "G=10*wcdf^9-9*wcdf^10"
View[., 1] = 10 :* View[., 2]:^9 :- 9 :* View[., 2]:^10

stata("list G wcdf, noobs separator(0)")
}
end

mata: createG()

set linesize `line_size'

exit