Announcement

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

  • Double if statement

    Hi all!

    This is my first post on STATALIST so I hope you can all help me out with a double if statement. My objective is to copy the value RE_total to REatCost_temp for companies that start putting out real estate assets data in year 1994 if RE_total is missing for the year 1993. If the company is already putting out real estate assets in 1993 I don't want to use the RE_total for 1994. A good overview is given in the uploaded picture below. As you can see for gvkey 1004 I do not whish to report the RE_total for year 1994, however for gvkey 1010 I do want to use it as 1993 is missing. I am looking forward to your response! Best Rick



    Click image for larger version

Name:	Screenshot 2022-07-18 at 14.15.22.png
Views:	1
Size:	130.5 KB
ID:	1673970

  • #2
    Thus the code would be something like:
    replace REatCost_temp = RE_total if year==1994 & RE_total!=. (& REatCost_temp==. for year 1993) the last part is incorrect.

    Comment


    • #3
      Rick, a correction to your code in #2 would be

      Code:
      bys gvkey (year): replace REatCost_temp = RE_total if year==1994 & RE_total !=. & REatCost_temp[_n-1] ==.

      Comment


      • #4
        Fei Wang Thanks a lot it worked!

        Comment

        Working...
        X