Hi
I have a panel data set where each individual has a unique 'RunnerID'. I want to remove all the IDs that have less than 3 observations from my data set
Hope you guys can help, thanks!
Do something like this
data have;
input RunnerID var;
datalines;
1 1
1 2
1 3
1 4
2 5
2 6
;
proc sql;
create table want as
select *
from have
group by RunnerID
having count(RunnerID) ge 3;
quit;
Please post samples data of what you HAVE and the expected OUTPUT(WANT) for your input. I mean a few records
The data I have looks like this, the data lines I want to keep are the yellow ones
Do something like this
data have;
input RunnerID var;
datalines;
1 1
1 2
1 3
1 4
2 5
2 6
;
proc sql;
create table want as
select *
from have
group by RunnerID
having count(RunnerID) ge 3;
quit;
Here is an example of one way using SASHELP.CLASS data.
Proc freq data=sashelp.class noprint; tables age /out=work.agecount (where=(count>3)); run; proc sql; create table want as select b.* from work.agecount as a left join sashelp.class as b on a.age=b.age ; quit;
"RunnerID would take the place of the variable Age in the above code. Obviously your data set would replace SASHELP.CLASS.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.