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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.