Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adotools - advanced managining of (project-)specific ado paths in Stata

adotools is a small collection of Stata utilities for defining, adding, removing, and clearing user-written ado paths. It is useful when working across multiple Stata projects, development folders, or synchronized directories where ado files should be made available only when needed.

Current Version: version release

Table of Contents

  1. Syntax
  2. Description
  3. Commands
  4. Options
  5. Examples
  6. How to install
  7. About
  8. Changes

Requires Stata 16.

1. Syntax

Define, list, remove, clear, import, or export named ado paths

adodefine [name], path(path) [using(filename)]
adodefine [name], remove [using(filename)]
adodefine, list [using(filename)]
adodefine, clear [using(filename)]
adodefine, from(filename)
adodefine, copy(filename [, excel]) [using(filename)]

Add named ado paths to the active Stata session

adoadd namelist [, from(filename) relative(path_prefix)]
adoadd _all [, from(filename) relative(path_prefix)]

Remove named ado paths from the active Stata session

adorm namelist [, from(filename) relative(path_prefix)]
adorm _all [, from(filename) relative(path_prefix)]

Clear the current Stata session and remove nonstandard ado paths

adoclear [, clear all]

name is the key used to identify an ado directory in the path definition dataset. namelist is one or more stored names. Use _all with adoadd or adorm to add or remove all stored paths.

2. Description

adotools manages named collections of Stata ado-path entries. The package stores a table of ado directories, usually in adodefine.dta, and lets the user add or remove selected directories from Stata's active adopath by name.

The intended workflow is:

  1. Use adodefine to create and maintain a dataset containing names and paths.
  2. Use adoadd to add one or more of those paths to the current Stata session.
  3. Use adorm to remove one or more of those paths and drop loaded programs from those paths.
  4. Use adoclear to reset the session and remove nonstandard ado paths.

The path definition dataset contains three variables:

Variable Description
id Numeric identifier for the path entry
name Name used by adoadd and adorm
path Directory added to or removed from Stata's ado path

3. Commands

adodefine

adodefine maintains the path definition dataset. At least one of path(), clear, remove, list, from(), using(), or copy() is specified depending on the task.

With path(), adodefine adds a new record. If name is omitted, adodefine attempts to use the basename of path() as the name.

With list, adodefine lists the records in the path definition dataset. With remove, it removes the records whose names match name. With clear, it creates a new empty path definition dataset.

adoadd

adoadd reads the path definition dataset, selects the requested names, and runs adopath + for each selected path. If _all is specified, all paths in the definition dataset are added.

adorm

adorm reads the path definition dataset, selects the requested names, drops any currently loaded ado programs found in those directories, and runs adopath - for each selected path. If _all is specified, all paths in the definition dataset are removed.

adoclear

adoclear can clear the data in memory and/or all frames, then removes nonstandard ado paths from the active Stata ado path. It does not remove Stata's standard path entries BASE, SITE, PERSONAL, PLUS, OLDPLACE, or .. It also rebuilds the Mata library index.

4. Options

adodefine options

Option Description
path(path) Adds path to the path definition dataset under name. If name is omitted, adodefine attempts to use the path basename as the name.
remove Removes the named entries from the path definition dataset.
list Lists the current path definition dataset.
clear Creates a new empty path definition dataset. If using() is specified, the empty dataset is saved there; otherwise the default adodefine.dta is used.
from(filename) Copies an existing path definition dataset to the folder containing adodefine.ado, saving it as adodefine.dta.
using(filename) Specifies the path definition dataset to read from or write to. If the file does not exist, adodefine creates an empty dataset with variables id, name, and path.
copy(filename [, excel]) Copies or exports the path definition dataset. Without excel, the dataset is copied as a Stata dataset. With excel, it is exported to Excel with variable names in the first row.

adoadd and adorm options

Option Description
from(filename) Reads path definitions from filename instead of the default adodefine.dta. If the filename has an Excel extension, the file is imported using import excel, firstrow; otherwise it is opened as a Stata dataset.
relative(path_prefix) Prefixes path_prefix to all paths read from the path definition dataset before adding or removing them. This is useful when the stored paths are relative to a project or synchronized folder.

adoclear options

Option Description
clear Clears the current dataset before removing nonstandard ado paths.
all May be combined with clear. Together, clear all is executed before nonstandard ado paths are removed.

5. Examples

The following examples follow the accompanying example.do file.

Create a default path definition dataset

Start by clearing the current ado-path definition file and adding project-specific ado directories.

adodefine , clear
adodefine xtdcce2, path("your folder")

List stored ado paths

adodefine , list

Remove a stored path definition

adodefine xtdcce2, remove
adodefine , list

Use a separate path definition file

A separate definition file can be created with using().

adodefine , clear using("your folders")
adodefine xtdcce2, path(folder to path") using("path to ado")

Add paths to the active session

Add selected paths:

adoadd xtdcce2

Add all paths:

adoadd _all

Remove paths from the active session

Remove selected paths:

adorm xtdcce2

Remove all paths:

adorm _all

Use an external definition file

adoadd xtgetpca, from("my_adodefine.dta")
adoadd xtgetpca, from("my_adodefine.xlsx")

Apply a common prefix to relative paths

adoadd _all, from("adodefine.dta") relative("D:\StataCode\")
adorm _all, from("adodefine.dta") relative("D:\StataCode\")

Clear the session and remove nonstandard ado paths

Clear the active dataset and remove nonstandard ado paths:

adoclear, clear

Clear all frames and remove nonstandard ado paths:

adoclear, clear all

6. How to install

Install from GitHub using Stata's net install command:

net install adotools, from("https://raw.githubusercontent.com/JanDitzen/adotools/main/") replace

Alternatively, clone or download the repository and add the folder containing the ado files to your Stata ado path:

adopath + "path/to/adotools"

After installation, type:

help adotools

7. About

Jan Ditzen (Free University of Bozen-Bolzano)

Email: jan.ditzen@unibz.it

Web: www.jan.ditzen.net

8. Changes

1.0.0

Initial public version.

About

Advanced managing of ado folders in Stata

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages