Bonjour à tous,
Je cherche à savoir la nature des enfants d’une femme, c’est-à-dire je veux savoir si elle a eu ses enfants avec le partenaire actuel ou celui précèdent (ou les deux).
L’idée est de construire une variable STATENF à deux modalités :
STATENF = 'cjt_pre' /*si la naissance a eu lieu au cours de la première relation */
STATENF = ‘ctj_act’ /*si la naissance a eu lieu au cours de la deuxième relation */
Dans ma base j’ai les éléments suivants :
IDMEN= identifiant ménage ;
COH1 = année de la première cohabitation qui s’est terminé par le mariage ;
MAR1 = année du mariage (qui a suivi COH1) ;
SEP1 = année de séparation (de facto) ;
DIV1 = année du divorce ;
COH2 = année de la deuxième cohabitation qui s’est terminé par le mariage (MAR2) ;
MAT2 = année du deuxième mariage (qui a suivi COH2) ;
Je cherche donc à savoir si les enfants sont nés dans une relation qui est tjs en cours ou si les enfants sont nés dans la relation précédente.
IDMEN COH1 MAT1 SEP1 DIV1 COH2 MAT2 ENF1 ENF2 ENF3
001 1980 1982 . 1990 . 1999 1985 2000 2001
002 . 1950 1960 1962 1970 . 1951 1953 1958 .
003 . 1990 1999 2001 1999 2005 1992 2000 .
Dans mon exemple pour l’IDMEN '001' l’ENF1 est né dans la relation précédente (STATENF = 'cjt_pre'), tandis que ENF2 et ENF3 sont nés dans la relation actuelle (STATENF = ‘ctj_act’) ;
Il y aura donc trois variables STATENF (STATENF1- STATENF3) pour les trois enfants de la base. J’ai essayé avec ce code, mais j’ai l’impression que les array n’aiment pas lorsqu’il y a une valeur manquante (ex IDMEN '001' pour SEP1 = . ‘la femme a divorcé du mari sans avoir vecu une période de séparation de facto).
data histcj3 ; set histcj2;
Pour que l’enfant soit né dans une relation précédente, il doit être né avant la séparation ou le divorce et avant la deuxième cohabitation ou le deuxième mariage ;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 data histcj3 ; set histcj2; array mar (2) COH1 MAR1 ; array sep (4) SEP1 DIV1 COH2 MAR2 ; do i=1 to 2; do j=1 to 4; if enf1 ne . and anenf1>= mar(i) and enf1<sep(j) then statenf1='cjt_pre'; if enf1 ne . and anenf1>= mar(i) and enf1>=sep(j) then statenf1='ctj_act' ; if enf2 ne . and enf2>= mar(i) and enf2<sep(j) then statenf2='cjt_pre'; if enf2 ne . and enf2>= mar(i) and enf2>=sep(j) then statenf2='ctj_act' ; if enf3 ne . and enf3>= mar(i) and enf3<sep(j) then statenf3='cjt_pre'; if enf3 ne . and enf3>= mar(i) and enf3>=sep(j) then statenf3='ctj_act' ; end ; end; run;
A contrario, un enfant est né dans la relation actuelle lorsqu’il est né après (ou au même temps que la nouvelle cohabitation ou le nouveau mariage = > ex IDMEN ‘0003’ la SEP1 a lieu au même temps que COH2).
Pour info, tous les individus de cette base ont mis à terme la première relation (MAR1).
Savez-vous comment je peux corriger mon bout de programme ?
Merci beaucoup pour votre aide !
Partager