Announcement

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

  • How to write immediate runable do-files despite links to data?

    Is it possible to write a do-file in such a way that every user can run them immediately without changing directories to a dataset?

    I am currently working in a group and we set up a dropbox folder for the dataset and our do-files, so everyone has the current version of the code easily accessible.
    However, the directory of dropbox is naturally different from each other, for example: C:\User A\dropbox and C:\User B\dropbox.

    In group sessions it is now very time consuming if we are working at the same time, someone wrote a new code, saves the do-file and the other group members have to change the directories again, so that it works.

    How do you proceed in group works? Is there any possibility to do this? I hope, it was not asked before, but I tried various combinations on the search engine.

  • #2
    Something like that should work if the users are working on windows environment:
    Code:
    cd "`:environment USERPROFILE'\Dropbox..."
    use mydata, clear

    Comment


    • #3
      Let me also recommend the recent discussion at the thread below, easily found by searching these forums for "dropbox", which turns up other threads as well.

      http://www.statalist.org/forums/foru...ile-in-dropbox

      Comment


      • #4
        I know it's commonly done but do-files should never use full pathnames. The moment you change computers or move the directory to a different location, you have to edit all the full pathnames everywhere. Instead, just change Stata's current directory to the shared Dropbox directory and then you can run anything using a simple filename, no path name required. If the files are in sub-directories, just use a relative pathname, e.g.

        Code:
        use "census/this_data.dta"
        Even better, look up project (from SSC). It will automatically align Stata's current directory with the directory of the currently running do-file.

        Comment


        • #5
          I know it's commonly done but do-files should never use full pathnames.
          Robert Picard's project is a great work flow tool. But, if you find the learning curve too steep, then I can strongly recommend fastcd (SSC) as a way of changing to directories for current projects prior to running do files

          Comment


          • #6
            Originally posted by Marius Schrade View Post
            I am currently working in a group and we set up a dropbox folder for the dataset and our do-files, so everyone has the current version of the code easily accessible.
            However, the directory of dropbox is naturally different from each other, for example: C:\User A\dropbox and C:\User B\dropbox.

            In group sessions it is now very time consuming if we are working at the same time, someone wrote a new code, saves the do-file and the other group members have to change the directories again, so that it works.
            Dropbox is not the appropriate tool to work concurrently on the same set of files. You are likely to create conflicting versions that you'll have to fix manually later on. See for example https://www.dropbox.com/en/help/36.

            What you need is a distributed version control system (for example Git https://git-scm.com/) and a repository (for example GitHub https://github.com/). A few repositories exist that allow you to host your projects privately for free (one is Bitbucket https://bitbucket.org/ , another is GitLab https://about.gitlab.com/gitlab-com/).

            A version control system has all kinds of safeguards and protocols for working concurrently on the same set of files. Dropbox doesn't. The former is about revision and collaboration, the latter mainly about syncing.
            You should:

            1. Read the FAQ carefully.

            2. "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!"

            3. Describe your dataset. Use list to list data when you are doing so. Use input to type in your own dataset fragment that others can experiment with.

            4. Use the advanced editing options to appropriately format quotes, data, code and Stata output. The advanced options can be toggled on/off using the A button in the top right corner of the text editor.

            Comment

            Working...
            X