STATA 随机


local sj=subinstr(subinstr("`c(current_time)'",":","",.)," ","",.)
local wjma="`sj'"
set seed `wjma'
clear
local shu= int(100*runiform() )
// local xm="ab cd ef gh add"
// local xma=split(`xm`)
set obs 100
disp `shu'
gen vab="张三"+string(_n)
if("`shu`"==string(_n)) disp vab[_n]
list  vab if _n==int(`shu'),noheader noobs

//清除内存
clear
//设置20个样本
set obs 20
//增加变量v1,都是this is the day
gen v1 = "this is the day"
//
gen v1_replace = subinstr(v1,"is","X",1)

*split
*1,2,3 -- > 1 2 3
clear
set obs 20
gen V1 = "1 2 3"
split v1,gen(a)
gen v2 = "1,2,3"
split v2 ,p(",") gen(b)

 

webuse auto, clear
set seed 20210426
gen rr=uniform()*10

 

posted @ 2023-03-07 21:06  myrj  阅读(31)  评论(0编辑  收藏  举报