1hello everyone, I am doing research paper and I need to select firm year observations rather than month year observation
No. company ID announcement date
1 0 5/2/2014
2 0 7/9/2014
3 0 1/4/2015
4 1 2/4/2013
5 1 4/8/2013
6 1 4/24/2013
7 2 2/6/2015
8 2 2/8/2016
as long as firms send announcements in a given year, the observation is included in the new sample. So I need to select No. 2, 3, 6, 7,8. How could I do it? I very appreciate your help.
Code like below should work.
proc sql;
/* create table want as*/
select *
from have
group by company_id, year(announcement_date)
having max(announcement_date)=announcement_date
;
quit;
Code like below should work.
proc sql;
/* create table want as*/
select *
from have
group by company_id, year(announcement_date)
having max(announcement_date)=announcement_date
;
quit;
You may as like to try the below code
data have;
input No company_ID announcement_date:mmddyy10.;
year=year(announcement_date);
format announcement_date date9.;
cards;
1 0 5/2/2014
2 0 7/9/2014
3 0 1/4/2015
4 1 2/4/2013
5 1 4/8/2013
6 1 4/24/2013
7 2 2/6/2015
8 2 2/8/2016
;
proc sort data=have;
by company_ID year announcement_date;
run;
data want;
set have;
by company_ID year announcement_date;
if last.year;
run;
Thank you so much! it works!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.