Announcement

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

  • downloading stata dataset

    Hi
    I have this do-file with cd "C:\Users\Dropbox\\Data Sets\Stata" and I don't know how to download it into my drive. What are the commands? I keep getting mixed up with pw and cd. I only know how to use the command from menu tab to import from excel, csv, txt file. Please help. Thank you.

  • #2
    Lena Gan mind posting the first 30 lines of said do file?

    Comment


    • #3
      cd changes the working directory to whatever directory provided after. In your example, it changes to "C:\Users\Dropbox\Data Sets\Stata" (I took one slash away assuming that's a typo.) Once the command is submitted, a statement like:
      Code:
      use dataset01, clear
      would actually mean
      Code:
      use "C:\Users\Dropbox\Data Sets\Stata\dataset01", clear
      The part set in cd is assumed and will be added even we didn't write that out explicitly. The problem is that if the data is actually somewhere else, then we can either use global to set an alternative path, or type the path directly.

      For example, if the data set is just in "Data Sets" rather than "Data Sets\Stata", but we have already set the cd using the command above, we can try:
      Code:
      use "C:\Users\Dropbox\Data Sets\dataset02", clear
      or:
      Code:
      global datalink "C:\Users\Dropbox\Data Sets"
      use "$datalink\dataset02", clear
      The global method is handy if you have files sitting at multiple places.

      pw (I believe you mean pwd) prints the current working directory simply returns what is the current directory. It will not change the directory, just printing.

      If you have been using point-and-click to import any data, you should already have access to the whole path. Every time a point and click command is ran in Stata, it's printed again in the output window, and also entered into the history panel:
      2021-10-17_23-27-30.png


      There you can extract the working syntax line, and also find out the full path of the data. In other words, if you can use point-and-click, you have all the materials to switch over to syntax.
      Last edited by Ken Chui; 17 Oct 2021, 21:36.

      Comment


      • #4
        Thank you Ken, that makes perfect sense.

        Comment

        Working...
        X