BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
2 REPLIES 2
yonib
SAS Employee
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;
Flip
Fluorite | Level 6
proc sort;
by id bld_pres;
run;

data new;
set old;
by id bld_pres;
if first.id and last.id;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 952 views
  • 0 likes
  • 3 in conversation