BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sfan6
Calcite | Level 5

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

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;

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

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;
Jagadishkatam
Amethyst | Level 16

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;
Thanks,
Jag
sfan6
Calcite | Level 5

Thank you so much! it works!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

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.

Discussion stats
  • 3 replies
  • 976 views
  • 0 likes
  • 3 in conversation