Skip to content

Packages

Alexandersax edited this page Aug 30, 2012 · 6 revisions

Packages provide an easy way to download and manage user-written commands in STATA and them. Our nice little package resides in the stata add-ons file at the address \\rtifile02\cidprojectshares\09354 EdData II\Task 3 EGRA\Final Databases\egrma-stata.

To install it, just paste net install rti_egrma, from("\\rtifile02\cidprojectshares\09354 EdData II\Task 3 EGRA\Final Databases\egrma-stata") into the STATA command prompt.

##What does it take to make a package? 2 things.

  • A stata.toc file
  • A .pkg file (for us, rti_egrma.pkg)

The stata.toc file just lists all of the packages in the folder (it points to their .pkg files). Right now, we have only 1 package, but at some point we might have more.

The .pkg file: pkg points to all the files associated with a package. It contains the paths to all the files that will be downloaded. The syntax is absurdly simple, a line beginning with f points to a file, a line beginning with a d is a comment. The line containing Distribution-date: tells STATA when the package was last released. If the user types adoupdate when they have an old package, stata will automatically let them know that this package (perhaps along with others), has a more recent version. The user can then update using adoupdate, update.

##What special things do you need to know about our package? We actually have two packages to facilitate better version-control. We work on everything in the test folder to isolate any changes or mistakes. Once the new code passes QA tests, we then move it up to production and commit it on GIT.

The test package resides in Final Databases/User/Alex/RTIegrma (test) and the production package resides in a hidden folder at Final Databases/egrma-stata. Because our production file is hidden, you'll want to set Windows Explorer to show hidden files by going to Tools > File Options > View > Show hidden folders and files. show hidden

Although you'll want to show the hidden files, you won't need to interact with the production folder directly, since you can move a file from test -> production from within stata by typing promote filename. Similarly, you can remove it from production but save a copy in test with rollback filename.


Now you just need some functions to put in the package.