Announcement

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

  • How to download WRDS variable label?

    Hi everyone,

    When I downloaded the wrds data from the website, the rdata file had variable labels so that I could clearly see the definition of each variable. However, when I downloaded the wrds data using stata, the raw data downloaded did not have variable labels.

    These are the codes. (odbc/jdbc)

    odbc load, exec("select * from comp.funda where datafmt = 'STD' and INDFMT = 'INDL' and variable description and fyear between 2020 and 2021 order by fyear limit 10") dsn("wrds")

    jdbc load, exec("select * from comp.funda where datafmt = 'STD' and INDFMT = 'INDL' and variable description and fyear between 2020 and 2021 order by fyear limit 10")


    I would like to know how to use stata to download wrds data that also has variable labels.

    Could you help me? ,please.
    Thank you very much.

  • #2
    I had tried the solution provided by the link, but it did't work.

    https://stackoverflow.com/questions/...mment-as-label



    Could you help me? ,please.
    Thank you very much.

    Comment


    • #3
      "It did not work" does not tell us much. What happened? Did your computer explode? Did it give an error message? What error message, and when did it occur? What did you try exactly?
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Thank you for your advice. More details are provided below.

        After I downloaded the WRDS data with stata 15, I followed the code provided with the link to get the variable label, but the following error message appeared and the variable label was not obtained.

        . mata: st_local("vars", invtokens(st_sdata(., ("name"))'))
        variable name not found
        st_sdata(): 3598 Stata returned error
        <istmt>: - function returned error

        r(3598);

        .
        . mata: st_local("labels", mm_invtokens(st_sdata(., ("comment"))'))
        variable comment not found
        st_sdata(): 3598 Stata returned error
        <istmt>: - function returned error

        r(3598);

        .
        . local n_vars = _N

        . forval i = 1/`n_vars' {
        2.
        . cap confirm variable `:word `i' of `vars''
        3.
        . if !_rc label var `:word `i' of `vars'' "`:word `i' of `labels''"
        4.
        . }




        Could you help me? ,please.
        Thank you very much.

        Comment


        • #5
          The code is based on the assumption that you have variables name and comment. You can check whether that is so with

          Code:
          describe name
          
          describe comment

          Comment


          • #6
            Thank you for your suggestion. I found no variable name and comment information after testing.

            . describe name
            variable name not found
            r(111);

            . describe comment
            variable comment not found
            r(111);

            How can such a problem be solved?
            Or is there another way to have a variable label?


            Could you help me? ,please.
            Thank you very much.

            Comment


            • #7
              Hi Kelly,

              My guess is that Compustat stores the variable labels in a dataset different from where it stores the data (comp.funda). I bet the WRDS folks can help you find that. Alternatively, you might consider downloading a minimal set of data from the web interface, and applying the labels you obtain that way to the data you download through Stata.
              Devra Golbe
              Professor Emerita, Dept. of Economics
              Hunter College, CUNY

              Comment


              • #8
                Thank you for your suggestion.
                I will request WRDS by mail and share more information with you.

                Comment


                • #9
                  The WRDS response is explained below
                  1.The data downloaded from the web query form were converted from the SAS dataset using PROC EXPORT in SAS, so the variable labels were preserved.
                  2.The data accessed from Stata was stored in our Postgres database, so the output did not have variable labels.
                  3.For technical reasons, WRDS cannot currently include variable labels when users download the data via WRDS Cloud queries.

                  →To get the variable labels, you will need to use the web query forms.

                  Comment

                  Working...
                  X