Dear All, Is it possible to install all the packages in SSC using one simple command (whatever that is)?
-
Login or Register
- Log in with
program define readPackageList, rclass args fileName cap file close fh //fh=filehandle; close if already in use file open fh using "`fileName'", read file read fh line while r(eof)==0 { //look for line formatted as "@net:describe pkgname!pkgname@" if index("`line'", "@net:describe") > 0 { // b=> index of character just after the string "@net:describe" local b =index("`line'", "@net:describe") + length("@net:describe") + 1 local e =index("`line'", "!") local pkgname= substr("`line'", `b', `e'-`b') local pkglist "`pkglist' `pkgname'" } file read fh line } file close fh return local pkglist="`pkglist'" end
global dryRun=0 global savename test1.txt set more off
foreach d in `c(alpha)' _ { noi ssc desc `d' , saving($savename, replace) readPackageList "$savename" noi di "Found packages: " r(pkglist) foreach a in `r(pkglist)' { noi di in yellow "Found package: `a'" if $dryRun !=1 { cap ssc install `a', all replace if _rc != 0 { noi di in red "Error downloading `a'" } } } }
foreach issue of numlist 1/61 { log using $savename, replace smcl net from http://www.stata.com/stb/stb`issue'/ log close readPackageList "$savename" foreach a in `r(pkglist)' { noi di in yellow "Found package: `a'" if $dryRun !=1 { net install `a', all replace } } }
local current_year = substr("$S_DATE",-4,4) local current_vol = `current_year' - 2000 foreach vol of numlist 1/`current_vol' { foreach issue of numlist 1/4 { // See whether it exists if yes, then actually install it cap net from http://www.stata-journal.com/software/sj`vol'-`issue' if _rc==0 { log using $savename, replace smcl net from http://www.stata-journal.com/software/sj`vol'-`issue' log close readPackageList "$savename" foreach a in `r(pkglist)' { noi di in yellow "Found package: `a'" if $dryRun !=1 { cap net install `a', all replace if _rc != 0 { noi di in red "Error installing `a'" } } } } } }
Comment