Announcement

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

  • variable not found and try to reshape datasets

    Hi I was trying to convert time series data into panel data but have been encountered some problems.

    Firstly my time series datasets are in following format:
    Company Name r2001 r2002 r2003
    AA PLC 2 4 7
    BB PLC 3 5 8
    CC PLC 7 9 9

    While I tried to import these data from excel to stata, once I imported, I opened data editor, then I realised the column company name are in red.

    Then I tried to reshape the data with following command, stata shows the following:
    reshape long r, i(name) j(year)
    variable name not found
    r(111);

    Can anyone told me why the company name column was in red in the first instance? How can I resolve this issue and reshape my data?

    Thank you!

  • #2
    Please post a sample of your data using the -dataex- command. See 12.2 of the FAQ: https://www.statalist.org/forums/help#stata
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3

      sorry I don't possibly understand the dataex so I rather use the table below to showcase.
      company name r2001 r2002 r2003
      aa plc 2 4 7
      bb plc 3 5 8
      cc plc 7 9 9
      where r2001 means year 2001. for example, for company aa plc, in 2001 the observation is 2.

      Comment


      • #4
        Enter the command: dataex
        in the command line of Stata. Copy and paste the output here. Please read the FAQ.
        Stata/MP 14.1 (64-bit x86-64)
        Revision 19 May 2016
        Win 8.1

        Comment


        • #5
          The Company Name column was in red because it is a string variable, rather than a numeric variable. Since you company names are not numbers, this is perfectly correct.

          Stata told you exactly what the problem is with the reshape command: having imported your dataset from Excel, there was no variable called "name". In the Data Editor, look at the top of the column containing the company name, that is the variable name you need. If it is the same as your Excel column name, then you neglected to tell import excel to take variable names from the first row of the spreadsheet, and you probably have other problems as well.

          Do follow the advice of the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

          In particular, read FAQ #12 and help those whose help you seek by posting example data using the dataex command. If you are running Stata 15.1 or later, it is already installed. For earlier versions of Stata, install dataex by typing ssc install dataex. Type help dataex to read the simple instructions for using it. Using dataex will enable those who want to help you to quickly and easily create a 100% faithful replica of your situation to test their ideas and code on.

          The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

          Comment


          • #6
            Thank you so much for your reply.

            Firstly, I did tell import excel to take variable names from the first row of the spreadsheet. There are 19 variables in my dataset: they are Name, r2000 to r2017. I can use describe command to any variables but not Name. Whenever run des name, stata would tell me:
            variable name not found
            r(111);

            I think there must be some error with the name variable but I really have no clue.

            Comment


            • #7
              You are still not using dataex as explained in the FAQ Advice #12 and as requested by Carole and William.

              Stata is case-sensitive. name is not Name. See [U] 11.3 in https://www.stata.com/manuals/u11.pdf

              So, possibly, this may work. If it doesn't, a data example is imperative.

              Code:
              reshape long r, i(Name) j(year)

              Comment


              • #8
                thank you so much guys! I managed to resolve the issue within my dataset. Cheers!

                Comment

                Working...
                X