Announcement

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

  • Share a Dof File - Current Directory

    Dear Statalist Users,

    I am currently working on a Stata model with panel data on working performance.

    Now I would like to share my model via a do file with my colleagues. We use a shared dropbox folder.

    My Do file looks like:
    Code:
    clear
    import excel " (filepath)\Dropbox\shared folder\Data.xls " firstrow
    ...
    Now I am wondering how my colleagues can open the Do File as their filepath "before dropbox" (i.e. C:\Users\Alexander-Florian\Dropbox....)
    will have a different name.

    But if i ask them to import the file manually then the clear command will delete the data.

    Is it adviseable to remove the clear and the import command from the do-file and manually write them to import the data from dropbox?

    Has anyone experience with this issue?

    Best, Alexander-Florian

  • #2
    Hi Alex,

    there's several possible solutions to your problem (which, by the way, is not a problem that is specific to Stata; I think that it is a question about how to implement a shared work flow).

    Under the assumption that each of your collaborators used the default path for his/her Dropbox folder, you could just replace the user-specific part with "~". The tilde character stands for "the current user's home directory", and Stata understands it on any platform:
    Code:
    clear
    import excel "~/Dropbox/shared folder/Data.xls" , firstrow
    Note that
    1. I inserted a comma separating the option firstrow from the import command, which makes it valid syntax;
    2. I switched your Windows-style backslash path separators to Stata-style forward slashes, which makes your syntax independent from the user's operating system (Windows/MacOS/Linux/Unix). Stata will make sure to translate the file path appropriately.
    If the general assumption that all collaborators use Dropbox's default paths does not hold, you end up with one of two variants
    1. use file path specifications relative to the do-file in your syntax, or
    2. continue to use absolute file paths, but construct them using macros.
    Variant 1. would read
    Code:
    clear
    import excel "Data.xls" , firstrow
    Variant 2. would read
    Code:
    clear
    local mainpath <your individual Dropbox path here>
    import excel "`mainpath'/Dropbox/shared folder/Data.xls" , firstrow
    Which one to choose is a matter of style.

    Regards
    Bela

    Comment


    • #3
      Bela,
      many thanks for your helpful reply
      Best, A.

      Comment

      Working...
      X