I have a data set where I want sum the variable epsfiq for two consecutive calendar years (ie 2020 and 2019) by a subgroup variable, cusip.
When I executed the code, it reflects missing variables even though the codition is met.
Here is the output of the data ( I included the dataex command below and you can see the variable missing. My question is why is rangestat returning missing variables when it seems like the condition is met?
. dataex cusip calyear epsfiq eps8qtr
----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input str10 cusip float calyear double(epsfiq eps8qtr)
"62945V109" 2011 . .
"62945V109" 2011 . .
"62945V109" 2011 . .
"62945V109" 2011 .36 .
"62945V109" 2012 -.09 .
"62945V109" 2012 .11 .
"62945V109" 2012 .17 .
"62945V109" 2012 .21 .
"62945V109" 2013 .23 .
"62945V109" 2013 .18 .
"62945V109" 2013 .23 .
"62945V109" 2013 .1 .
"62945V109" 2014 .13 .
"62945V109" 2014 .19 .
"62945V109" 2014 .31 .
"62945V109" 2014 .25 .
"62945V109" 2015 .18 .
"62945V109" 2015 .25 .
"62945V109" 2015 .38 .
"62945V109" 2015 .33 .
"62945V109" 2016 .25 .
"62945V109" 2016 .31 .
"62945V109" 2016 .33 .
"62945V109" 2016 .31 .
"62945V109" 2017 .21 .
"62945V109" 2017 .4 .
"62945V109" 2017 .55 .
"62945V109" 2017 1.06 .
"62945V109" 2018 .39 .
"62945V109" 2018 .69 .
"62945V109" 2018 .62 .
"62945V109" 2018 .62 .
"62945V109" 2019 .44 .
"62945V109" 2019 .7 .
"62945V109" 2019 .46 .
"62945V109" 2019 .28 .
"62945V109" 2020 .33 .
"62945V109" 2020 .36 .
"62945V109" 2020 .61 .
"62945V109" 2020 .35 .
"62945V109" 2021 .41 .
"62945V109" 2021 .91 .
"62945V109" 2021 .83 .
"62945V109" 2021 1.02 .
"62945V109" 2022 .57 .
"62945V109" 2022 1.13 .
"62945V109" 2022 1.05 .
When I executed the code, it reflects missing variables even though the codition is met.
Code:
describe sort cusip datadate gen calyear=year(datadate) rangestat (sum) eps8qtr=epsfiq, int(calyear 2020 2019) by(cusip)
. dataex cusip calyear epsfiq eps8qtr
----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input str10 cusip float calyear double(epsfiq eps8qtr)
"62945V109" 2011 . .
"62945V109" 2011 . .
"62945V109" 2011 . .
"62945V109" 2011 .36 .
"62945V109" 2012 -.09 .
"62945V109" 2012 .11 .
"62945V109" 2012 .17 .
"62945V109" 2012 .21 .
"62945V109" 2013 .23 .
"62945V109" 2013 .18 .
"62945V109" 2013 .23 .
"62945V109" 2013 .1 .
"62945V109" 2014 .13 .
"62945V109" 2014 .19 .
"62945V109" 2014 .31 .
"62945V109" 2014 .25 .
"62945V109" 2015 .18 .
"62945V109" 2015 .25 .
"62945V109" 2015 .38 .
"62945V109" 2015 .33 .
"62945V109" 2016 .25 .
"62945V109" 2016 .31 .
"62945V109" 2016 .33 .
"62945V109" 2016 .31 .
"62945V109" 2017 .21 .
"62945V109" 2017 .4 .
"62945V109" 2017 .55 .
"62945V109" 2017 1.06 .
"62945V109" 2018 .39 .
"62945V109" 2018 .69 .
"62945V109" 2018 .62 .
"62945V109" 2018 .62 .
"62945V109" 2019 .44 .
"62945V109" 2019 .7 .
"62945V109" 2019 .46 .
"62945V109" 2019 .28 .
"62945V109" 2020 .33 .
"62945V109" 2020 .36 .
"62945V109" 2020 .61 .
"62945V109" 2020 .35 .
"62945V109" 2021 .41 .
"62945V109" 2021 .91 .
"62945V109" 2021 .83 .
"62945V109" 2021 1.02 .
"62945V109" 2022 .57 .
"62945V109" 2022 1.13 .
"62945V109" 2022 1.05 .
Comment