BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MBlack732
Fluorite | Level 6

this is from BIST0535.hw3_1

As you can see I have sorted data by subject and then dov, such that the observations for a single subject are all clumped together and the observation from the first time they visited (date of visit, dov) is first. I need to create a new data set BIST0535.hw3_2 which contains only one observation from each subject with the first time they visited. I think we are meant to use an IF THEN statement, however if there is a easier way I am open to it.

Obs subject dov dbp sbp
107/09/1998108157
109/23/1998107134
210/15/1998114149
201/14/1999112165
204/15/1999105158
207/22/1999115143
307/22/1998103148
310/07/1998107165
301/14/1999102159
401/23/200087110
404/26/200085128
511/10/199965137
502/10/200066108
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

if i understand you,

 

all you need is 

 

if first.subject;

 

 

data want;

set have;

by subject dov;

if first.subject;

run;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

if i understand you,

 

all you need is 

 

if first.subject;

 

 

data want;

set have;

by subject dov;

if first.subject;

run;

Jagadishkatam
Amethyst | Level 16
data want;
set have;
by subject;
if first.subject;
run;
Thanks,
Jag
MBlack732
Fluorite | Level 6

Thank you! For some reason it was giving me an error about the BY statement, but i guess there was a need for a PROC SORT before this could occur.

novinosrin
Tourmaline | Level 20

Yes @MBlack732 By group processing does require ordering

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 4 replies
  • 1513 views
  • 0 likes
  • 3 in conversation