*! bringin--use large data sets automatically *! version 1.0 Robert Farmer (dm21: STB-22) /* BRINGIN.ado This ado file works EXACTLY like BMEMSIZE. bringin filename [obs | vars ] bringin filename == bmemsize filename followed by F4 bringin filename vars == bmemsize filename followed by F5 bringin filename obs == bmemsize filename followed by F6 */ program define bringin pause on version 3.0 if "`1'" == "" { display "SYNTAX: bringin filename [(nothing)| vars | obs]. Quitting with no action." pause exit } local obs = index("`1'",",") - 1 if `obs' > 0 { local 1 = substr("`1'",1,`obs') } capture confirm file `1'.dta if _rc ~= 0 { display "`1' is apparently not a STATA dataset. Quitting with no action" pause exit } quietly describe using `1', detail short local obs = _result(1) local var = _result(2) local width = _result(3) local os = _result(4) local vs = _result(5) local ws = _result(6) if `width'*`obs' > `ws'*`os'-10000 { di _col(8) in red "insufficient total memory" exit } capture bmemsize using `1' if "`2'" ~= "" { if "`2'" == "obs" { local xxx = substr("$F6",11,index("$F6","width")-11) local yyy = substr("$F6",index("$F6","width ")+6,length("$F6")-(index("$F6","width ")+6)) } if "`2'" == "vars" { local xxx = substr("$F5",11,index("$F5","width")-11) local yyy = substr("$F5",index("$F5","width ")+6,length("$F5")-(index("$F5","width ")+6)) } } else { local xxx = substr("$F4",11,index("$F4","width")-11) local yyy = substr("$F4",index("$F4","width ")+6,length("$F4")-(index("$F4","width ")+6)) } clear set maxvar `xxx' width `yyy' use `1' exit end