Announcement

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

  • Anyone use wdireshape? Why do I have error code r(111) though I use exactly the same code in example?

    Hi,

    I try to use World Development Indicators data in Stata. I import the excel file from world bank by using insheet command.

    Then, I find out "wdireshape" is useful to reshape WDI data from wide into long.
    I type exactly the same code as shown in example in "help box":
    wdireshape v1-v57, prepend(yr) ctyname(countryname) sern(seriesname) ctycode(countrycode) sercode(seriescode)


    But, I have this error code:
    yr1 ambiguous abbreviation
    r(111);


    I don't understand why. I have read the author Jeanty's paper, but no explanation! I search google, but still cannot find any answers.

    Please someone helps me. Thank you so much!!


  • #2
    There are a couple of things that would help diagnose your problem:
    1. As per the Statalist FAQ, please indicate where wdireshape comes from (SSC in this case).
    2. Please show the exact insheet command you used to import the data. It may also be helpful to show the results of describe so that we can see what the data looks like.
    3. Please explain what you mean by "help box". Are you referring to the help for wdireshape?

    Comment


    • #3
      One more thing: what happens when you do wdireshape, sern(seriesname) ?

      Comment


      • #4
        I have the same problem. I am using stata 13.1 and have downloaded wdireshape. this is the error i get

        yr1 ambiguous abbreviation

        when i use the wdireshape, sern(seriesname) it seems to be working

        1) Domestic credit to private sector (% of GDP)
        2) Exports of goods and services (% of GDP)
        3) General government final consumption expenditure (% of GDP)
        4) Gross savings (% of GNI)
        5) Imports of goods and services (% of GDP)

        then i continue with the usual command sequence

        . wdireshape ppp sss ddd ccc gdf ///
        > ,prepend(yr) ctyname(countryname) sername(seriesname) ///
        > sercode(seriescode) ctycode(countrycode) ///
        >
        (5 missing values generated)
        yr1 ambiguous abbreviation
        r(111);

        I wonder if the problem is due to the recent update in the wdi website design, Any help would be greatly appreciated.

        Regards

        Comment


        • #5
          I have also considered the possibility that wdireshape may not work properly because of missing values. i dropped all the variables with missing values (..) . Still received the same error message

          Comment


          • #6
            What are the varnames of your year variables prior to reshape? Is there a variable named "yr1"? I presume what's happening is that you have variables named "yr1960" and so forth. Try adding the options "byp(1) start(1960) end(2004)".

            Comment


            • #7
              Ive tried out the wdireshape. The issue is it looks for variables (abbreviated) yr1, yr2 etc. and that doenst work, because when looking for yr1, it finds variables called yr1990, yr1991 etc., and cant decide which of the two is yr1. I dont understand the mechanics of wdireshape entirely, but somehow it works on the basis of renaming both original year names and seriesnames into v1-vx and yr1-yrx, before it executes reshape, and renames them into something useful (and acceptable for Stata) after that.

              Long story short: yes, updates in WDI format may have made wdireshape not work anymore.
              Fortunately there is still the 'backup' option of reshape. You could do:
              Code:
              reshape long yr, i(countrycode seriescode) j(Year)
              replace seriescode = subinstr(seriescode, ".", "",.)
              drop seriesname
              reshape wide yr, i(countrycode Year) j(seriescode) string
              rename yr* *
              This will give you long data, which should be most commonly used.
              Alternatively, create useful names for the seriescodes you are interested in first, so that you have useful variable names

              Comment


              • #8
                Hi everyone, I had a same problem but thanks to the answer from Nils Enevoldsen, the problem was solved. My data range from 1960 to 2020 so I add "byp(10) start(1960) end(2020)", byp(10) is suitable for my data range and faster, but byp(1) would fit in most cases.

                Jorrit Gosens's code also has the right spirit, but for the whole dataset with 1433 indicators the long to wide step exceeds the variable maximum constraint. The same method can also be found in https://dss.princeton.edu/training/D...01.pdf#page=23

                FYI

                Comment

                Working...
                X