- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 03-06-2019 02:48 PM
(750 views)
Hi all,
I have a large data set with ID, PARITY, BREEDING DATE, FARROWING DATE AND WEANING DATE variables. I need to create a new variable that can show the weaning date of the previous PARITY within the same ID. In all PARITY 1 I need a "." in the NEW VARIABLE.
This is what I need to achieve:
Any help provided will be greatly appreciated!!!
Best regards,
Francisco
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try using a lag variable. I have not tested it but how about something like;
proc sort data=have;
by id parity;
run;
data want;
set have;
new_variable=lag(weaning_date);
if first.id then new_variable=.;
run;