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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1014 views
  • 0 likes
  • 3 in conversation