Announcement

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

  • How do I load data in Stata from the internet? I am not able to make -webuse- work...

    Good morning,

    I am trying to load from within Stata a file on this website https://www.lisdatacenter.org/resources/self-teaching/, it is in the column LIS sample files, US16 Household dataset.

    So I went to the side, right clicked on the file, and copy link address. Then from withing Stata I typed

    Code:
    . webuse https://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta
    file
        http://www.stata-press.com/data/r15/https://www.lisdatacenter.org/wp-content/uploads/files/us1
        > 6ih.dta not found
    r(601);
    
    .
    So this did not do the trick. Then I tried

    Code:
    . webuse set https://www.lisdatacenter.org/wp-content/uploads/files/
    (prefix now "https://www.lisdatacenter.org/wp-content/uploads/files")
    
    . webuse us16ih.dta
    sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath
    > .SunCertPathBuilderException: unable to find valid certification path to requested target
    r(5100);
    and this did not do the trick either.

    Do you know how I can retrieve a file from the web from within Stata?

  • #2
    Code:
    copy http://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta .
    use us16ih

    Comment


    • #3
      This did not work either , Andrew.

      Code:
      . copy http://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta
      invalid file specification
      r(198);
      
      . use us16ih
      file us16ih.dta not found
      r(601);
      Originally posted by Andrew Musau View Post
      Code:
      copy http://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta .
      use us16ih

      Comment


      • #4
        Don't omit the dot at the end.

        Comment


        • #5
          Try
          Code:
          use http://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta
          (use instead of webuse and http instead of https)
          https://www.kripfganz.de/stata/

          Comment


          • #6
            How do you know this magic???

            First, if I put the dot attached, it generates an error, but it still works:

            Code:
            . copy http://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta.
            invalid file specification
            r(198);
            
            . use us16ih.dta
            (us16: version created on 20 Apr 2019 18:50)
            and then when I put the dot exactly as you have done it, with one space in between, the magic works without errors:

            Code:
            . copy http://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta .
            
            . use us16ih.dta
            (us16: version created on 20 Apr 2019 18:50)
            Originally posted by Andrew Musau View Post
            Don't omit the dot at the end.

            Comment


            • #7
              I have seen it in an example in the Stata manual. Also, see

              Code:
              help copy

              Comment


              • #8
                Thank you Sebastian, this is all perfect. With this way I can use all I know about -use- including retrieving only the variables I want::

                Code:
                . clear
                
                . use http://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta
                (us16: version created on 20 Apr 2019 18:50)
                
                . use hid dhi using http://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta
                (us16: version created on 20 Apr 2019 18:50)


                Originally posted by Sebastian Kripfganz View Post
                Try
                Code:
                use http://www.lisdatacenter.org/wp-content/uploads/files/us16ih.dta
                (use instead of webuse and http instead of https)

                Comment

                Working...
                X