Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LIBNAME LIBRARY 'D:\Users\AdelinouxX\Desktop\Travail_SAS\FORMAT';
- LIBNAME OUT 'D:\Users\AdelinouxX\Desktop\Travail_SAS\DATA';
- /* --------------------------------------------------------------------------------------------------------------------------------
- ETAPE 2 : S?lection et des variables
- - Cr?ez un nouveau dataset permanent "ess2012VF" (? stocker dans la librairie OUT)? partir du dataset ESS6E02_1_F1
- - Conservez uniquement la liste de variables suivantes au moyen d'un KEEP statement :
- - Variable d'int?r?t : DMCNTOV
- - Explicatives socio-d?mographiques : REGION EISCED HINCFEL AGEA
- - Explicatives "th?matiques" : POLINTR BLGETMG PLINSOC
- /* --------------------------------------------------------------------------------------------------------------------------------*/
- data out.ess2016VF;
- set out.ESS8e02_0_F1;
- keep AESFDRK AGEA basinc dfincac DOMICIL EISCED emplrel GNDR HAPPY health HINCFEL icpart1 lknemny imprich impfree inprdsc ipeqopt iphlppl lvgptnea MNACTIC PPLTRST RLGDGR SBLAZY sblwcoa SCLMEET sclact wkhtot;
- run;
- *NB : V?rifiez que le dataset a bien ?t? cr??
- - via le log : NOTE: The data set OUT.ESS2012VF has 1869 observations and 8 variables.
- - via la fen?tre Explorateur --> Biblioth?ques --> OUT --> double-clic sur le dataset Ess2012vf --> VIEWTABLE
- !!!! Veillez ? toujours fermer la VIEWTABLE avant d'ex?cuter la suite du programme !!!!;
- /* -------------------------------------------------------------------------------------
- ETAPE 3 : Examiner les caract?ristiques des variables retenues via la PROC CONTENTS
- Que constate-t-on?
- ------------------------------------------------------------------------------------- */
- proc contents data = out.ess2016VF varnum;
- run;
- /* -----------------------------------------------------------------------------------------------------------------
- ETAPE 4 : Cr?ez un format "age" pour discr?tiser la variable AGEA de la mani?re suivante ? l'aide de PROC FORMAT
- <20 ; [20-30[; [30-40[; [40; 50[; [50-60[; [60-70[; [70-80[; >=80
- Stocker le format dans la librairie LIBRARY
- ----------------------------------------------------------------------------------------------------------------- */
- proc format library = library;
- value age low-<20 = '<20'
- 20-<30 = '[20-30['
- 30-<40 = '[30-40['
- 40-<50 = '[40-50['
- 50-<60 = '[50-60['
- 60-<70 = '[60-70['
- 70-<80 = '[70-80['
- 80-high = '>=80';
- run;
- /* ---------------------------------------------------------------------------------------------------------------------------------------
- ETAPE 5 : Appliquer la PROC FREQ sur l'ensemble des variables
- Assigner le format age ? la variable agea pour observer les effectifs par cat?gorie plut?t que pour
- chaque valeur sp?cifique de la variable continue (NB : l'assignation est temporaire dans un bloc PROC)
- Utiliser l'option NLEVELS pour afficher ?galement la liste du nombre de niveaux.
- Dirigez les sorties vers un fichier pdf qui sera stock? dans le sous-dossier RESULTS que vous avez cr?? dans votre espace de travail.
- Pour ce faire, utilisez l'instruction ODS, appliquez le style "Journal", supprimez l'affichage de la date et donnez
- le titre suivant ? votre rapport : 'Distribution des variables initiales'.
- --------------------------------------------------------------------------------------------------------------------------------------- */
- ods pdf file = 'D:\Users\AdelinouxX\Desktop\Travail_SAS\results\rapport1.pdf' style = journal;
- options nodate;
- title 'Distribution des variables initiales';
- proc freq data = out.ess2016VF nlevels;
- format agea age.;
- run;
- title;
- ods pdf close;
- /* ---------------------------------------------------------------------------------------------------------------
- ETAPE 6 : Cr?er de nouvelles variables pour recoder les variables initiales via des IF THEN ELSE statements.
- En tenant compte de la r?partition des effectifs, regroupez les cat?gories de mani?re pertinente pour d?finir
- les nouvelles variables suivantes :
- 1. La variable d'int?r?t doit ?tre recat?goris? en 2 niveaux (EVALDEMO2) en 4 niveaux (EVALDEMO4)
- 2. POLINTR et HINCFEL doivent ?tre recat?goris?es en 2 niveaux au d?part de 4 (POLINTR2 HINCFEL2)
- 3. EISCED doit ?tre recod?e en 3 niveaux (EDUC3 : "Low", "Middle", "High")
- 4. PLINSOC doit ?tre recod?e en 3 niveaux (PLINSOC3 : "Top", "Middle", "Bottom")
- 5. REGION doit ?tre recod?e en 3 niveaux (REG3 : "Bxl", "Fl", "Wal")
- Le nouveau dataset permanent doit s'appeler "datarecod".
- --------------------------------------------------------------------------------------------------------------- */
- data out.datarecod;
- length basinc2 $ 9 dfincac2 $ 15 HAPPY3 $ 22 health3 $ 17 inprdsc3 $ 11 sclact2 $ 11 sblazy3 $ 9 impfree3 $ 16 imprich3 $ 16
- lknemny3 $ 13 sblwcoa3 $ 9 iphlppl3 $ 16 ipeqopt3 $ 16 hincfel2 $ 16 educ3 $ 9 domicil2 $ 16 mnactic2 $ 10 ppltrst3 $ 17 sclmeet2 $ 11 aesfdrk2 $ 13 rlgdgr3 $ 16 wkhtot3 $ 21 ;
- set out.ess2016VF ;
- *1. La variable d'int?r?t recat?goris?e en 2 et en 4 niveaux;
- if 1 <= dfincac <= 2 then dfincac2 = 'A)D accord' ;
- else if 3 <= dfincac <= 5 then dfincac2 = 'B) Pas d accord' ;
- if 0 <= HAPPY <= 7 then HAPPY3 = 'A)Malheureux' ;
- else if 8 <= HAPPY <= 8 then HAPPY3 = 'B) Moyennement heureux' ;
- else if 9 <= HAPPY <= 10 then HAPPY3 = 'C) Heureux' ;
- if basinc in (1,2) then basinc2 = "A) Contre";
- else if basinc in (3,4) then basinc2 = "B) Pour";
- if 0 <= inprdsc <= 3 then inprdsc3 = 'A) Peu' ;
- else if 4 <= inprdsc <= 4 then inprdsc3 = 'B) Moyen' ;
- else if 5 <= inprdsc <= 6 then inprdsc3 = 'C) Beaucoup' ;
- if 1 <= health <= 2 then health3 = 'A) Bonne santé' ;
- else if 3 <= health <= 3 then health3 = 'B) Neutre' ;
- else if 4 <= health <= 5 then health3 = 'C) Mauvaise santé' ;
- if 1 <= sclact <= 2 then sclact2 = 'A) Peu' ;
- else if 3 <= sclact <= 5 then sclact2 = 'B) Beaucoup' ;
- if 1<= HINCFEL <=2 then HINCFEL2='A) Confortable' ;
- else if 3<= HINCFEL <=4 then HINCFEL2='B) Difficile' ;
- if DOMICIL in (1,2,3) then DOMICIL2 = "A) Plutôt urbain";
- else if DOMICIL in (4,5) then DOMICIL2 = "B) Plutôt rural";
- if mnactic in (1,2) then mnactic2 = "A) Actif";
- else if mnactic in (3,4,5,6,7,8) then mnactic2 = "B) Inactif";
- else if 0 <= ppltrst <= 4 then ppltrst3 = 'A) Peu confiant' ;
- else if 5 <= ppltrst <= 6 then ppltrst3 = 'B) Assez confiant' ;
- else if 7 <= ppltrst <= 10 then ppltrst3 = 'Très confiant' ;
- if 1 <= sclmeet <= 5 then sclmeet2 = 'A) Peu' ;
- else if 6 <= sclmeet <= 7 then sclmeet2 = 'B) Beaucoup' ;
- if 1 <= sblazy <= 2 then sblazy3 = 'A) Oui' ;
- else if 3 <= sblazy <= 3 then sblazy3 = 'B) Neutre' ;
- else if 4 <= sblazy <= 5 then sblazy3 = 'C) Non' ;
- if 1 <= impfree <= 1 then impfree3 = 'A) Important' ;
- else if 2 <= impfree <= 2 then impfree3 = 'B) Neutre' ;
- else if 3 <= impfree <= 6 then impfree3 = 'C) Pas important' ;
- if 1 <= imprich <= 2 then imprich3 = 'A) Important' ;
- else if 3 <= imprich <= 3 then imprich3 = 'B) Neutre' ;
- else if 4 <= imprich <= 6 then imprich3 = 'C) Pas important' ;
- if 1 <= iphlppl <= 2 then iphlppl3 = 'A) Important' ;
- else if 3 <= iphlppl <= 3 then iphlppl3 = 'B) Neutre' ;
- else if 4 <= iphlppl <= 6 then iphlppl3 = 'C) Pas important' ;
- if 1 <= ipeqopt <= 1 then ipeqopt3 = 'A) Important' ;
- else if 2 <= ipeqopt <= 2 then ipeqopt3 = 'B)Neutre' ;
- else if 3 <= ipeqopt <= 6 then ipeqopt3 = 'C) Pas important' ;
- if 1 <= sblwcoa <= 2 then sblwcoa3 = 'A) Oui' ;
- else if 3 <= sblwcoa <= 3 then sblwcoa3 = 'B) Neutre' ;
- else if 4 <= sblwcoa <= 5 then sblwcoa3 = 'C) Non' ;
- if aesfdrk in (1,2) then aesfdrk2 = 'A) Sécurisé';
- else if aesfdrk in (3,4) then aesfdrk2 = 'B) Insécurisé';
- if 1 <= lknemny <= 1 then lknemny3 = 'A) Pas du tout' ;
- else if 2 <= lknemny <= 2 then lknemny3 = 'B) Plutôt pas' ;
- else if 3 <= lknemny <= 4 then lknemny3 = 'C) Assez' ;
- if 0 <= rlgdgr <= 2 then rlgdgr3 = 'A) Pas religieux' ;
- else if 3 <= rlgdgr <= 6 then rlgdgr3 = 'B) Peu religieux' ;
- else if 7 <= rlgdgr <= 10 then rlgdgr3 = 'C) Religieux' ;
- if 1 <= EISCED <=2 then educ3 = "A) Peu";
- else if 3 <= EISCED <= 5 then educ3 = "B) Moyen";
- else if 6 <= EISCED <= 7 then educ3 = "C) Haut";
- if 1 <= wkhtot <= 36 then wkhtot3 = "A) Moins de 37h/sem";
- else if 37 <= wkhtot <= 42 then wkhtot3 = "B) De 37 à 42h/sem";
- else if 43 <= wkhtot <= 156 then wkhtot3 = "C) Plus de 42h/sem";
- run;
- proc contents data = out.datarecod varnum;
- run;
- data out.datalabel;
- set out.datarecod;
- label
- basinc2 = 'Against or In favour of a basic income scheme - 2 levels'
- dfincac2 = 'Large differences in income acceptable to reward talents and efforts - 2 levels'
- HAPPY3 = 'How happy are you - 3 levels'
- health3 = 'Subjective general health - 3 levels'
- inprdsc3 = 'How many people with whom you can discuss intimate and personal matters - 3 levels'
- sclact2 = 'Take part in social activities compared to others of same age - 2 levels'
- sblazy3 = 'Social benefits/services make people lazy - 3 levels'
- impfree3 = 'Important to make own decisions and be free - 3 levels'
- imprich3 = 'Important to be rich, have money and expensive things - 3 levels'
- lknemny3 = 'How likely not enough money for household necessities next 12 months - 3 levels'
- sblwcoa3 = 'Social benefits/services make people less willing care for one another - 3 levels'
- iphlppl3 = 'Important to help people and care for others well-being - 3 levels'
- ipeqopt3 = 'Important that people are treated equally and have equal opportunities - 3 levels'
- hincfel2 = 'Feeling about household s income nowadays - 2 levels'
- educ3 = 'Highest level of education, ES - ISCED - 3 levels'
- domicil2 = 'Domicile, respondent s description - 2 levels'
- mnactic2 = 'Main activity, last 7 days. All respondents. Post coded - 2 levels'
- ppltrst3 = 'Most people can be trusted or you can t be too careful - 3 levels'
- sclmeet2 = 'How often socially meet with friends, relatives or colleagues - 2 levels'
- aesfdrk2 = 'Feeling of safety of walking alone in local area after dark - 2 levels'
- rlgdgr3 = 'How religious are you - 3 levels' ;
- run;
- proc contents data = out.datalabel varnum;
- run;
- ods pdf file = 'D:\Users\AdelinouxX\Desktop\Travail_SAS\RESULTS\rapport2.pdf' style = journal;
- title1 'Evaluation de la d?mocratie en Belgique';
- title2 'Variables explicatives socio-d?mographiques';
- proc freq data = out.datalabel;
- tables
- health3*happy3
- sclact2*happy3
- lknemny3*happy3
- sblwcoa3*happy3
- hincfel2*happy3
- sclmeet2*happy3
- /nopercent nocol;
- run;
- title;
- ods pdf close ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement