BookmarkSubscribeRSS Feed
mantubiradar19
Quartz | Level 8

I have a longituidnal data (Called as SBP & DBP which are contineous variables)- which is collected on different dates and the date variable looks like 10SEP2010. I have sample ID for each patient.

 

I would like to classify first measurement of SBP, DBP of each observation into one dataset and last measurement of SBP, DBP of each observation into another dataset. 

 

How can I do this?

5 REPLIES 5
zzone
Calcite | Level 5

Browse source dataset by patient_ID and sampling_date. Output first record of a group to one dataset and the last to another. something like code below. 

 

data destination_dataset1 destination_dataset2;

  set source_dataset;

  by patient_id sampling_date;

  if first.patient_id then output destination_dataset1;

  if last.patient_id  then output destination_dataset2;

run;

mantubiradar19
Quartz | Level 8
Thank you very much Zzone! Let me try this!
mantubiradar19
Quartz | Level 8

I'm trying to computete the difference between first and last observations. Can someone tell me why I have the following note? 

 

Thanks


Capture.JPG
zzone
Calcite | Level 5

"first" / "last" refer to a subgroup which means ordering. Your code does not browse the data set in an ordered manner (you should have a "by ... " clause in it.

I'd suggest you should read a little bit the basics to understand the mechanisms behind:

http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001302699.htm

 

mantubiradar19
Quartz | Level 8
Thanks for the reference!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 5 replies
  • 2266 views
  • 0 likes
  • 2 in conversation