Announcement

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

  • Downloading data from internet

    Hello, I need to download data from this website. Technically, to download data one is supposed to click on "query data" or "all data", which sends to this link, which downloads the data. However, I can't seem to do it on Stata. Is there a way to do it automatically? I have tried infield, insheet and import commands.

  • #2
    Unless you know that the dataset is a Stata dataset (i.e., a .dta file), then it is easier to download it to a directory on your computer and import it to Stata. If it is an Excel file, see

    Code:
    help import excel
    If it is text-delimited data, see

    Code:
    help import delimited

    and so on. For imports, I rarely use code the first time around as you will want to know certain details, e.g,, whether the data starts in the first row, where the variable names are, etc. So after reading the documentation, click on File \(\rightarrow\) Import \(\rightarrow \; \cdots \)
    Last edited by Andrew Musau; 05 Oct 2021, 06:32.

    Comment


    • #3
      Thank you. It is an excel file, but the problem is that the link does not seem to work on stata directly. I know I can import and then upload in Stata, but I need to do it directly.

      Comment


      • #4
        The data is stored in a ZIP file, so you need a few steps. But something like

        Code:
        copy "https://api.unhcr.org/population/v1/asylum-decisions/?download=true#_ga=2.211754517.1436380706.1633434402-1680802646.1633434402" query_data.zip, replace
        unzipfile query_data.zip, replace
        import delimited  "asylum-decisions.csv", delimiter(comma) clear

        Comment


        • #5
          Thank you so much! This works

          Comment


          • #6
            Andrew Musau (or anybody), is it possible to download data as a table from this website: https://app.powerbi.com/view?r=eyJrI...BiZSIsImMiOjh9 ?

            Comment


            • #7
              I do not see how you do it without writing some web scraping code, but I may be wrong. Maybe others will have better ideas.

              Comment


              • #8
                May I get a data set on ordinal logistic regression for teaching purpose

                Comment


                • #9
                  The Stata manual has examples and datasets included in the entries of commands. In this case, see

                  Code:
                  help ologit

                  Comment

                  Working...
                  X