Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72772

keep the last observation based on a group of variables

$
0
0
Dear Statalisters,

Below is sample of my data :


:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str3 ticker int analys double value int(fpedats anndats)
"ASA" 8856 3.8 8369 8398 
"ASA" 18000 3.71 8369 8447 
"ASA" 31000 3.9 8369 8417 
"ASA" 31000 3.94 8369 8468 
end
format %tddd-Mon-YY fpedats
format %tddd-Mon-YY anndats

I did the following:
:
 bysort ticker analys fpedats anndats : keep if _n==_N
I thought for analys 31000 , only the one record will kept, but still no observation dropped.

What am I missing here?

Regards,
rochelle

Viewing all articles
Browse latest Browse all 72772

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>