Announcement

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

  • Generating a new variable year-1/year+1

    Dear all,

    I have one question, if i want to generate a new variable starting from an existing one but the new variable should be year -1 or year +1 from old variable.
    What is the command in stata for this operation?

  • #2
    The question depends on the organization of your data and the time intervals between observations. Please provide example data, and use the -dataex- command to do that. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    In the meantime, you may perhaps find what you are looking for by reading -help tsvarlist-.

    Comment


    • #3
      Hello,

      Many thanks for your prompt response, I attached the regression. The variable in question is CFO, in regression this variable is analyzed for year t, year t+1, and year t-1.

      Sourcehttps://onlinelibrary.wiley.com/doi/...UhfR94MVv8BU1S)

      Attached Files
      Last edited by Catalin Mos; 25 Jul 2022, 03:38.

      Comment


      • #4
        Hi, Catalin: 1. Please see the following example:
        Code:
        webuse grunfeld, clear
        xtset company year
        xtreg invest L.mvalue mvalue F.mvalue D.kstock, fe robust
        2. As mentioned by @Clyde Schechter,
        Code:
        When asking for help with code, always show example data. When showing example data, always use -dataex-.
        Ho-Chuan (River) Huang
        Stata 19.0, MP(4)

        Comment


        • #5
          Dear River,

          Many thanks for your response, I understand the code. I have a panel data for the period 2015-2021 (2015 and 2021 are used only to have data for period T-1/T+1 for the year 2016/2020). My equitation is ACC(i)(T)= Constant + CFO(i)(T-1)+CFO(i)(T)+CFO(i)(T+1)+Other variables(i)(T).
          My question is how to define variable CFO in order to include all the mentioned periods (T-1, T, and T+1) in the equation.

          Many thanks,
          I am grateful for your understanding

          Comment

          Working...
          X