Announcement

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

  • Merging Deflator Values to a Panel

    Hi, I have a panel data (large n and small T) with -id- as the panel variable and -year- as the time variable. The year variable ranges from 2000-2003 and id captures the number of firms.
    In addition to this, I have sales value for each of the firm. It is an unbalanced panel.

    Just a snippet of how it looks (I have around 20,000 firms):


    --id-- --year-- --sales
    1 2000 43,722
    2 2000 32,000
    2 2001 16,000
    3 2000 20,001
    3 2001 22,768
    3 2002 26,890
    3 2003 21,760

    Now, I have another dataset (dta.file) which has CPI deflator values by year i.e. from 2000-2003.

    In order to get sales (in real terms), for example, for firm 1, I have to divide the sales by the 2000 deflator value and multiply by 100. While, I can do this manually, I am looking for a code to first add the deflator using some code and then generating the real sales.

    How to proceed?




  • #2
    In the future, when showing data examples, please use the -dataex- command to do so. If you are running version 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.

    Also, it would have been helpful to have an example of the CPI deflator file.

    That said, assuming the file with the CPI deflator is organized one observation per year and contains two variables named year, and deflator, you can do this as follows:

    Code:
    use your_panel_dataset, clear
    merge m:1 year using deflator_dataset
    That will bring the deflator into your data set and then you can procee4d to inflation-adjust.

    [quote]
    While, I can do this manually,
    ...[/code]
    No, no, no, no, no! Unless you are just doing this for amusement, you should never do this kind of thing manually. First, it is error-prone. And, just as important, if you are doing this for any serious purpose you must always do things in a way that leaves an audit trail so that both you and others who see your work can verify that things were done correctly. This type of thing should always be done in a do-file, with a log-file of results kept--both files being memorialized for at least a few years beyond the release date of the results. No responsible person should ever take seriously, let alone rely on, an analysis that is not so documented.

    Comment

    Working...
    X