0% found this document useful (0 votes)
12 views5 pages

Exemple Correction TP1

TP sondage

Uploaded by

Yatoute Mintoama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Exemple Correction TP1

TP sondage

Uploaded by

Yatoute Mintoama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

/***************************************/

/******* Exemple de corrigé TP1 *******/


/*************************************/

/*Exercice 1 :*/
/*Question 1 :*/

Libname source "D:\Users\yesstafa\Bureau\TP1" ACCESS=READONLY;


Libname resultat "D:\Users\yesstafa\Bureau\TP1\Resultat";

/*Question 2 :*/

DATA resultat. RP12_d35;


SET source. Rp12_d35;
run;

/*Question 3 :*/

Proc print data= resultat. RP12_d35(obs=20);


run;

/*Question 4 :*/

Proc contents data=resultat. RP12_d35;


run;

/*Question 5 :*/

Proc means data=resultat. RP12_d35 Median;


VAR age;
WEIGHT IPONDI;
run;

Proc means data=resultat. RP12_d35 Median NOOBS;


VAR age;
WEIGHT IPONDI;
class SEXE;
run;

/*Question 6 :*/

Proc univariate data=resultat. RP12_d35 noprint;


Weight IPONDI;
OUTPUT out=resultat. deciles P10=D1 P50=medianne P90=D9;
Var Age;
Class sexe;
run;

DATA resultat. deciles;


set resultat. deciles;
FORMAT INTER 4.2;
INTER = (D9-D1)/medianne;
run;
/*Question 7 :*/

Proc univariate data=resultat. RP12_d35;


var Age;
weight ipondi;
output out = resultat. age_descreptif MEAN=Moyenne MEDIAN=Medianne
MAX=Maximum Min=Minimum;
run;

/*Question 8 :*/

Proc SGPLOT data= resultat. RP12_d35;


VBOX AGE / WEIGHT=IPONDI;
run;

PROC SGPLOT data= resultat. RP12_d35;


HISTOGRAM AGE / WEIGHT=IPONDI binstrat=0 binwidth=1;
run;

/*Question 9 :*/

Proc SGPLOT data=resultat. RP12_d35;


VBOX AGE /CATEGORY= SEXE WEIGHT=IPONDI;
YAXIS grid;
run;

/*Question 10 :*/

Proc univariate data=resultat. RP12_d35;


QQPLOT AGE;
RUN;

/*Question 11 :*/

PROC MEANS DATA = resultat. RP12_d35 MEAN;


VAR AGE;
WEIGHT IPONDI;
output out=resultat. moyenne;
RUN;

Data resultat. moyenne;


set resultat. moyenne(firstobs=4 obs=4);
keep Age;
rename Age=Moy;
run;

data resultat. RP12_d35;


merge resultat. RP12_d35 resultat. moyenne;
if moy = "." then moy=0;
retain Moyenne 0;
Moyenne=sum(Moyenne,moy);
drop moy;
run;
data resultat. RP12_d35;
set resultat. RP12_d35;
ECM=IPONDI*AGE-Moyenne;
run;

data resultat. RP12_d35;


set resultat. RP12_d35;
retain cumul_ECM 0;
cumul_ECM=sum(cumul_ECM,ECM);
run;

/*Question 12 :*/

data resultat. RP12_d35;


set resultat. RP12_d35;
select;
when (age>=0 and age <18) AGETRANCHE="[0;18[";
when (age>=18 and age <26) AGETRANCHE="[18;26[";
when (age>=26 and age <40) AGETRANCHE="[26;40[";
when (age>=40 and age <55) AGETRANCHE="[40;55[";
when (age>=55 and age <65) AGETRANCHE="[55;65[";
when (age>=65 and age <80) AGETRANCHE="[65;80[";
OTHERWISE AGETRANCHE ="[80;+[";
END;
RUN;

/*Question bonus :*/

proc freq data = resultat. RP12_d35;


table AGE * SEXE / out = resultat. pop_par_age noprint;
weight ipondi;
run;

data resultat. pop_par_age;


set resultat. pop_par_age;
if sexe = 1 then
count = -count;
run;

proc sgplot data = resultat. pop_par_age;


hbar age / RESPONSE = COUNT GROUP = SEXE;
yaxis reverse label = "Population";
xaxis label = "Âge";
run;

/*Exercice 2 :*/
/*Question 13 :*/

DATA resultat. revenu;


SET source. revenu;
run;

DATA resultat. revenu;


set resultat. revenu;
select;
when (revenu>=0 and revenu <= 4) TRANCHE_REV ="[0;4]";
when (revenu>4 and revenu <= 7) TRANCHE_REV ="]04;7]";
when (revenu> 7 and revenu <= 12) TRANCHE_REV ="]07;12]";
when (revenu> 12 and revenu <= 20) TRANCHE_REV ="]12;20]";
OTHERWISE TRANCHE_REV="]20;+[";
END;
RUN;

/*Question 14 :*/

PROC freq data= resultat. revenu;


TABLE tranche_rev / out=resultat. eff_tranche;
run;

data resultat. eff_tranche;


set resultat. eff_tranche;
KEEP TRANCHE_REV PERCENT;
run;

/*Question 15 :*/

DATA resultat. eff_tranche;


set resultat. eff_tranche;
rename percent=pct_effectif;
run;

/*Question 16 :*/

PROC TABULATE DATA = resultat. revenu out = resultat. REVENU_TOT_TRANCHE;


TABLES tranche_rev,revenu*pctsum;
VAR revenu;
CLASS tranche_rev;
RUN;

DATA resultat. REVENU_TOT_TRANCHE;


SET resultat. REVENU_TOT_TRANCHE;
KEEP TRANCHE_REV revenu_PctSum_0_revenu;
RUN;

/*Question 17 :*/

DATA resultat. revenu_tot_tranche;


SET resultat. revenu_tot_tranche;
RENAME revenu_PctSum_0_revenu =PCT_REV;
RUN;

/*Question 18 :*/

DATA resultat. donnees_gini;


MERGE resultat. eff_tranche resultat. revenu_tot_tranche;
BY tranche_rev;
RUN;

/*Question 19 :*/

DATA resultat. donnees_gini;


SET resultat. donnees_gini;
pct_effectif_cum + pct_effectif;
pct_revenu_cum + pct_rev;
RUN;

/*Question 20, 21 et 22 :*/

PROC SORT DATA = resultat. donnees_gini;


by descending pct_effectif_cum;
run;

DATA resultat. donnees_gini;


SET resultat. donnees_gini;
pct_effectif_cum_suivant = LAG(pct_effectif_cum);
pct_revenu_cum_suivant = LAG(pct_revenu_cum);
RUN;

PROC SORT DATA = resultat. donnees_gini;


BY pct_effectif_cum;
RUN;

DATA resultat. donnees_gini;


SET resultat. donnees_gini;
trapeze_elem = (pct_effectif_cum_suivant -
pct_effectif_cum)*(pct_revenu_cum_suivant + pct_revenu_cum)/20000;
RUN;

PROC SGPLOT DATA = resultat. donnees_gini;


SERIES x = pct_effectif_cum Y = pct_revenu_cum;
SERIES x = pct_effectif_cum Y = pct_effectif_cum;
TITLE 'Courbe de Lorenz';
XAXIS LABEL = "Proportion des effectifs cumulés";
YAXIS LABEL = "Proportion des revenus cumulés";
run;

You might also like