Announcement

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

  • reshaping to long with a string ID

    I want to reshape my data from wide to long. I implement:
    Code:
    reshape long MortgageloansthUSD2010 MortgageloansthUSD2011 MortgageloansthUSD2012 MortgageloansthUSD2013 MortgageloansthUSD2014 MortgageloansthUSD2015 MortgageloansthUSD2016 MortgageloansthUSD2017, i(BankName) j(year)
    but this returns an error that varsa# and b# could not be found. Here is a MWE for my data;
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str3 A str45 BankName double(MortgageloansthUSD2017 MortgageloansthUSD2016 MortgageloansthUSD2015 MortgageloansthUSD2014 MortgageloansthUSD2013 MortgageloansthUSD2012) byte(MortgageloansthUSD2011 MortgageloansthUSD2010)
    "1."  "Bank of Botswana"                                             .                .                .                .                .                . . .
    "2."  "First National Bank of Botswana Ltd"                          .                .                .                .                .                . . .
    "3."  "ABC Holdings Limited-BancABC"                                 .                .                .                .                .                . . .
    "4."  "Barclays Bank of Botswana Limited"                            .                .                .                .                .                . . .
    "5."  "Standard Chartered Bank Botswana Ltd"                         .                .                .                .                .                . . .
    "6."  "Stanbic Bank Botswana Limited"                                .                .                .                .                .                . . .
    "7."  "Letshego Holding Limited"                                     .                .                .                .                .                . . .
    "8."  "African Banking Corp of Botswana Ltd"                         .                .                .                .                .                . . .
    "9."  "Bank Gaborone Limited"                                        .                .                . 73095.1800710261 34878.9616196975                . . .
    "10." "Botswana Building Society"                     329977.240228072 299613.889747657 283554.947920002 296896.851364613 290070.461801015                . . .
    "11." "First Capital Bank"                                           .                .                .                .                .                . . .
    "12." "Botswana Savings Bank"                          78967.653999038 75348.9914702401 52268.3491211385                .                . 22036.1025966704 . .
    "13." "Bank of Baroda (Botswana) Limited"                            . 8252.18597841263 8231.59042349458 8164.67244613171 9090.06063134968                . . .
    "14." "National Development Bank"                                    .                .                .                .                .                . . .
    "15." "Money Quest Investments (Proprietary) Limited"                .                .                .                .                .                . . .
    "16." "Bank SBI Botswana Ltd"                                        .                .                .                .                .                . . .
    "17." "Bank Of India (Botswana) Limited"                             .                .                .                .                .                . . .
    "18." "Norsad Finance Limited"                                       .                .                .                .                .                . . .
    end
    ------------------ copy up to and including the previous line ------------------
    Is the i variable the problem? How do I implement the reshape?

  • #2
    You only need to give the stub of the variable names when reshaping long, i.e. the part of the variable name excluding the year.
    Code:
    reshape long MortgageloansthUSD, i(A BankName) j(year)

    Comment


    • #3
      The statement of Wouter Wakker needs to be strengthened:

      You need to give the stub, and only the stub, of the variable names when reshaping long

      Comment


      • #4
        Thanks Nick and Wakker. I must confess I had tried this:
        Code:
         
         reshape long MortgageloansthUSD*, i(A BankName) j(year)
        I know this is not the right place to ask further but it escapes my logic on where * is usable for iterative variable names.

        Nonetheless, this works for me! Thanks.

        Comment


        • #5
          No; that command does not work as the wildcard expands to a set of variable names, not one or more stubs.

          Comment

          Working...
          X