Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Telling Stata18 the Directory for User-Written Commands

    Hi, and I apologize in advance for some newbie questions. Today I was looking for the suite of commands written by Thomas Grund that is a useful suite for social network research. The title for the commands is nwcommands. I found out that Stata does not maintain a link to these commands at this point, but that they can be downloaded from Github. I did that, and I made a subdirectory that contains nwcommands. But where should I place this subdirectory so that Stata can access these ado and help files? And how should I refer to the directory within Stata? As I said, these are newbie questions.

  • #2
    Where to put them depends on your setup. Launch Stata and run the command -adopath-. You will get output that looks something like this, but with pathnames reflecting your actual setup:
    Code:
    . adopath
      [1]  (BASE)      "C:\Program Files\Stata18\ado\base/"
      [2]  (SITE)      "C:\Program Files\Stata18\ado\site/"
      [3]              "."
      [4]  (PERSONAL)  "C:\Users\clyde\ado\personal/"
      [5]  (PLUS)      "C:\Users\clyde\ado\plus/"
      [6]  (OLDPLACE)  "c:\ado/"
    The best place to put your commands is in the path that appears after (PLUS). You will likely find that that directory is, itself, subdivided into directories, one for each letter in the alphabet. If so, put the commands in the subdirectory n, since that is the first letter of nwcommands.

    Comment


    • #3
      That answers the question. Thanks very much, and wow, that is a lot of posts! Thanks for your help.

      Comment


      • #4
        I don't have \ado\plus/ directories there, but I suppose that I can simply create them?

        Comment


        • #5
          What does your ouput from -adopath- look like?

          Comment


          • #6
            The adopath output looked exactly like the one you mentioned except for my name. What I see is [5] (PLUS) "C:\Users\jdada\ado\plus/" And yet the ado and plus subdirectories are not visible when I am in the jdadad directory. So still puzzled as to the procedure.

            Comment


            • #7
              SOLUTION. Reading through the sysdir command in Stata, I learned that after you install user-written commands into a directory, you have to issue adopath + <directory> so that the commands are visible to Stata. Here is my example. Step 1: load the nwcommands written by Thomas Grund into this directory: C:\Users\jdada\ado\plus\n. In my case, I had to create the ado and n subdirectories, but they work fine so no worries. Also make sure that the user-written commands are in \n and not at some lower level on the directory path. Step2: issue this command: adopath + C:\Users\jdada\ado\plus\n . You need to add this path to the adopath that Stata uses so that Stata can find the user-written code, in my case nwcommands. These two steps worked. But note that the path just added is only for that Stata session. It is temporary. As long as you place it at the top of a program using the particular user-written commands, that won't cause any problems. You can also make the extra path permanent if you plan on using the user-written commands in the long run. Details can be found under sysdir. Many thanks to Clyde Schechter for getting me on the right "path".

              Comment


              • #8
                I'm not an authority on Thomas Grund's package, but I do not recommand following James Adams SOLUTION in #7.

                There is a much easier way to install the nwcommands packages without having to make changes to your adopath, and that conforms with how you install other packages, like with command ssc.

                If you followed the above instructions, I would remove the plus folder -- it has been put into a bad state.

                If you had to create the plus folder, just remove it and follow the instructions in my the next post.

                If you already had a plus folder, then I would get a list of the installed packages before removing it, so you can recover your installed packages later. I would use the following code to create a log with the list of my ado packages before removing the plus folder.

                Code:
                log using ado-list.txt
                ado
                log close
                The list of packages and the locations they were installed from will be saved to the log file ado-list.txt.

                Comment


                • #9
                  Here is how I installed the nwcommands packages.

                  1. Download the ZIP or use git clone to get a working copy of the repository. On my computer I have a folder named git where I clone stuff from GitHub. My terminal session looked something like this.
                  Code:
                  $ cd ~/git
                  $ git clone https://github.com/ThomasGrund/nwcommands.git
                  This created a folder named nwcommands in my git folder.

                  2. Start Stata, and use the cd command to change Stata's current directory to where you unzipped the ZIP file or cloned the repository. On my computer I typed the following in Stata:
                  Code:
                  . cd ~/git/nwcommands
                  3. Use command net from with the location of the current directory.
                  Code:
                  . new from "`: pwd'"
                  Note my use of double quotes. The macro function pwd should return the current working directory in your Stata session, and if you are on windows, that path might have spaces.

                  The output from this should look something like this.
                  Code:
                  . net from "`:pwd'"
                  -----------------------------------------------------------------------
                  /Users/jsp/git/nwcommands/
                  nwcommands Social Network Analysis Using Stata
                  -----------------------------------------------------------------------
                  
                  Program by Thomas Grund, Linkoping University, IAS
                  
                  PACKAGES you could -net describe-:
                      nwcommands-ado    Social Network Analysis Using Stata - Core
                      nwcommands-hlp    Social Network Analysis Using Stata - Help Files
                      nwcommands-dlg    Social Network Analysis Using Stata - Dialogs
                      nwcommands-ext    Social Network Analysis Using Stata - Extensions
                  -----------------------------------------------------------------------
                  4. In your Stata session, you can click on any of the (blue highlighted) links in the first column of the above table to describe and install the corresponding package of files.

                  5. Although it appears this repository was last changed on Dec 10, 2015, I would keep the working copy in my git/nwcommands/ folder. If there is an update to the repository on GitHub, you will be able to pull the changes into your working copy, then update the Stata packages with command ado update.

                  Comment


                  • #10
                    Hi Jeff, Thanks for the input. I did want to say that effectively, my solution is the one recommended by Stata Corporation under the sysdir command. (I agree that you can wreck your copy of Stata by fooling with the wrong directory, which I was careful not to do.) The "bad state" for the plus subdirectory disappears on the next Stata session. Also, the SSC depository of additions to Stata at Boston College automatically does what I did manually in relation to Grund's nwcommands. I was happy because I got my work done, but I think that all this needs to be sorted out by Stata itself. And finally, I appreciate Stata for its cutting edge commands, but I am puzzled as to the shifting status of user written commands. In 2015, when Grund's nwcommands debuted, they were included in Stata, but now they have disappeared. And while I typically use R and iGraph to do social network analysis, there is an extremely useful operation provided by nwcommands, and that is the conversion of a matrix to an edgelist, and vice versa. That operation is of general interest and I think it deserves to be supported by Stata. I am puzzled by the disappearing status of nwcommands. Please make it simpler to access user-written commands in the future, and thank you in advance for doing so.
                    Last edited by James Adams; 22 Feb 2024, 06:34.

                    Comment


                    • #11
                      You can install nwcommand without first cloning the repository:

                      Code:
                      . net from "https://raw.githubusercontent.com/ThomasGrund/nwcommands/master"
                      -------------------------------------------------------------------------------------------------------------------------------
                      https://raw.githubusercontent.com/ThomasGrund/nwcommands/master/
                      nwcommands Social Network Analysis Using Stata
                      -------------------------------------------------------------------------------------------------------------------------------
                      
                      Program by Thomas Grund, Linkoping University, IAS
                      
                      PACKAGES you could -net describe-:
                          nwcommands-ado    Social Network Analysis Using Stata - Core
                          nwcommands-hlp    Social Network Analysis Using Stata - Help Files
                          nwcommands-dlg    Social Network Analysis Using Stata - Dialogs
                          nwcommands-ext    Social Network Analysis Using Stata - Extensions
                      -------------------------------------------------------------------------------------------------------------------------------
                      ---------------------------------
                      Maarten L. Buis
                      University of Konstanz
                      Department of history and sociology
                      box 40
                      78457 Konstanz
                      Germany
                      http://www.maartenbuis.nl
                      ---------------------------------

                      Comment

                      Working...
                      X