Dear Statalister,

I would like to ask how can I create a code for the following variable (See attaches pic)?

I am trying to create a dummy variable that equal to 1 if firm i used IFRS in year t and used non-IFRS in year t-1.

Firstly, I create a dummy variable: IFRS equal to 1 if firm used “accounting standards followed” code 2, 6 or 23 and zero otherwise:

Sort id fyear

gen IFRS=AS==2|AS==6|AS==23

Then, I generate a dummy variable to find IFRS change in order to find out firm that used IFRS in year t and used non-IFRS in year t-1:

gen IFRSChg=0
replace IFRSChg=1 if IFRS=1 & IFRS[_n-1]=0

But it ends up with a problem. The code doesn’t work. Stata shows that I don’t have a time variable. But I sort the data with fiscal year. Can someone please help me? I don’t know how to correct my code. Thank you.

Help would very appreciated!

Best,

Mimi