whereis
command provides a convenient way to keep track of resource locations by maintaining a directory or registry of external files and folders, making things simple for developers and users alike.whereis [name [location]] |
name
argument specifies the name of a resource, and must be a single word conforming to Stata conventions for names, with no spaces.location
argument is used when registering a resource and should be a full path specifying the location of the file or folder. This must conform to Stata conventions for file names. In particular, it should be enclosed in quotes if it includes spaces.name
and location
it checks that the named file or folder exists and creates or updates an entry in its registry. If only a name
is specified the command retrieves and prints the location of the named resource and checks that it exists. In both cases the location is stored in a macro called r(name)
using the name of the resource.pandoc
document converter. Suppose pandoc
was installed at c:program files (x86)pandocpandoc.exe
. How can we pass this information to the command?pandoc()
option, so the user can type pandoc(c:program files (x86)pandocpandoc.exe)
among the options. Unfortunately this procedure is tedious and error prone, as the path has to be specified every time the program is used.global PANDOC c:program files (x86)pandocpandoc.exe
, and an even better one is to store this macro in the user's profile.do
file, so it will be loaded when Stata starts up. There is a slight inefficiency in defining the macro regardless of whether the resource will be used, but presumably only a small number of programs would be involved for any given user.whereis
command provides a simpler solution. Once pandoc
has been installed, the user registers its location by typing in Stata the one-time command whereis pandoc 'c:program files (x86)pandoc.exe'
, where we have used quotation marks because the full path to the command includes spaces.pandoc
uses the one-liner whereis pandoc
. The whereis
command will print the location of the file and, being an r-class command, will also store it in the macro r(pandoc)
, where it can be retrieved.whereis
to store the location of folders Edit vcd files. as well as files, and indicated how to modify the code to enable this extension. Free winter templates for mac. Their teams use GitHub and Dropbox with the same project folder structure, but everyone has a different GitHub or Dropbox root. Storing the root with whereis
provides a uniform way to refer to project files and folders.whereis
approach over storing global macros in profile.do
are that the resource location is retrieved only on demand, and more importantly, the command checks that the file or folder exists at the given location, both on storage and retrieval. This feature can be important when Stata executes a command by ``shelling out', as the failure may not be noticed immediately.which
that can find an executable by searching the user's path. If you are not quite sure where pandoc
was installed in your Mac, open a terminal window (select Applications, Utilities and then Terminal) and type which pandoc
. This will list the path to the executable if found. (There is also a Unix whereis
command, after which this Stata command is named, which searches the standard locations for binary files, but I have obtained better results with which
.)where
. By default this searches only the user's path, but there is an option to search recursively. If you think pandoc
was installed in your C drive try opening a command prompt window and typing where /R c: pandoc.exe
.whereis
command.whereis
to access a resource should allow for the possibility that the path may include spaces. For example to execute pandoc
one could codepandoc
has not been registered with whereis
or if the file is not found in the specified location.whereis
command is available from the Statistical Software Components (SSC) archive and can be installed by typing in Statasearch whereis
and follow the links. The current version is 1.4, and became available on SSC on 28 feb 2020.A development version is kept on this server, but I recommend you use the SSC version.