Help using Base SAS procedures

select observations

Reply
N/A
Posts: 0

select observations

I have more observations for the same subject, what i want to do is select only subjects with one observetion. How can I do this?
dataset is similar to this:
id blood pressure
1 130
2 120
3 140
3 160
3 125
4 120
4 135
4 130

i want only subjects with one misuration i.e subject number 1 and 2 in this example
thank you
SAS Employee
Posts: 105

Re: select observations

Posted in reply to deleted_user
Hi ,
There are several ways of doing it ,
For example :

data temp;
input id blood_pressure;
cards;
1 130
2 120
3 140
3 160
3 125
4 120
4 135
4 130
;
run;
proc sql;
create table temp2 as
select b.*
from(

select count(id) as count
,id
from temp
group by id
having count(id)=1
) as a
join temp as b
on a.id=b.id;
quit;
Super Contributor
Posts: 359

Re: select observations

Posted in reply to deleted_user
proc sort;
by id bld_pres;
run;

data new;
set old;
by id bld_pres;
if first.id and last.id;
run;
Ask a Question
Discussion stats
  • 2 replies
  • 109 views
  • 0 likes
  • 3 in conversation