Hi all
I have this code working correctly to get 4 records of each COW_ID by using all my dataset that contained 10 years of records, but I need to get 4 records for each cow_id for each year.
my data called have
I have the variable YEAR in this data
So How I can to specify my requirement by using this code?
best regards
barkamih
PROC SQL;
create table want as
select *
from have
group by COW_ID
having count(*) > 3 ;
RUN;
PROC SQL;
create table want as
select *
from have
group by COW_ID, year
having count(*) > 3 ;
RUN;
group by COW_ID, year
PROC SQL;
create table want as
select *
from have
group by COW_ID, year
having count(*) > 3 ;
RUN;
group by COW_ID, year
group by year, COW_ID
Good catch
Not a catch at all. I hadn't seen your submission before I posted. Both will give the same result, but sorted differently.
And both will be wrong if OP wanted cow_id's with 4 records in every year...
Oh Sir, I think you comprehended -", but I need to get 4 records for each cow_id for each year. " this correctly
both of you are correct, the first reply get accepted and the second one got like, I'm trying to be equal for both of you hahaha, I hope I did.
I appreciate your response
thanks million my friends
It's all good. Just a thought, I think it;s better to end proc sql with quit; than run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.