%include;ancdes_stat
%( death date year - spouse death date year tf1/tl1 = nxd %)
%define;stat_a2()
%if;(evar.m = "A")
[*generation/generations]0 |
%end;
[*year/month/day]0 [death] - [year/month/day]0 [death] x |
[*date of death] |
%end;
%define;anc_a()
%apply;stat_a2()
%foreach;ancestor_level(l_v)
%empty_sorted_list;
%reset_count;
%if;(level > 1 and (evar.only != "on" or level = l_v))
%foreach;ancestor;
%if;(ancestor.is_male and ancestor.same = "")
%if;(ancestor.death_date.year != "" and ancestor.spouse.death_date.year != "")
%let;l1;%ancestor.death_date.year;%in;
%let;l2;%ancestor.spouse.death_date.year;%in;
%if;(l1 >= l2)
%let;l3;%expr(l1 - l2)%in;
%incr_count;
%apply;add_in_sorted_list(l1,l3,ancestor.sex,ancestor.index)
%elseif;(l1 < l2)
%let;l3;%expr(l2 - l1)%in;
%incr_count;
%apply;add_in_sorted_list(l2,l3,ancestor.spouse.sex,ancestor.spouse.index)
%end;
%end;
%end;
%end;
%apply;stat2()
%end;
%end;
%end;
%define;des_a2(curlev, maxlev)
%foreach;family;
%if;(curlev < maxlev and family.desc_level = curlev)
%family.set_infinite_desc_level;
%if;(death_date.year != "" and death_date.prec = ""
and spouse.death_date.year != "" and spouse.death_date.prec = "")
%let;a;%death_date.year;%in;
%let;b;%spouse.death_date.year;%in;
%incr_count;
%if;(a >= b)
%let;l_age;%expr(a - b)%in;
%apply;add_in_sorted_list(a,l_age,sex,index)
%elseif;(a < b)
%let;l_age;%expr(b - a)%in;
%apply;add_in_sorted_list(b,l_age,spouse.sex,spouse.index)
%end;
%end;
%if;(has_children)
%foreach;child;
%apply;des_a2(curlev+1, maxlev)
%end;
%end;
%end;
%end;
%end;
%( main %)
%apply;togen()
%if;(evar.m = "A")
%apply;anc_a()
%else;
%apply;stat_a2()
%reset_desc_level;
%reset_count;
%empty_sorted_list;
%apply;des_a2(0,l_v)
%apply;stat2()
%end;