1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
| libname examen 'C:\Users\MOI\Desktop\tp SAS';
/*creation de la fenetre menu*/
%window menu
#4 @28 "Menu"
#7 @5 "1:Saisie des donnees"
#8 @5 "2:Affichage des donnees"
#9 @5 "3:Realisation de l'analyse appropriee"
#10 @5 "4:sortie"
#11 @5 "Quel est votre choix:"
@30 choix 1 attr=underline
#16 @5 "tapez entree pour continuer";
%display menu;
/*creation de la fenetre IMPORT*/
%window IMPORT
#4 @20 "Saisie des donnees"
#7 @5 "chemin complet de la table:"@35 chemin 50 attr=underline
#8 @5 "nom de l'identifiant:"@35 id 20 attr=underline
#11 @5 "tapez sur entree pour continuer";
%display IMPORT;
/*creation de la fenetre nonsaisie*/
%window nonsaisie
#4 @28 "Erreur 11"
#7 @5 "vous n''avez pas encors saisie des donnees"
#11 @5 "Tapez entree pour continuer";
%display nonsaisie;
/*fenetre question*/
%window question
#3 @15 "Repondez SVP"
#7 @5 "1:Est ce que vous avez 2 varibles groupe"
#9 @5 "2:Est ce que vous avez plus de 2 varibles qualitatives"
#11 @5 "3:Est ce que vous avez des varibles quantitatives"
#13 @5 "Faites voter choix"
@38 rep 1 attr=underline
#15 @10 "Tapez sur entree pour continuer";
%display question;
%macro importation ;/*importation de fichier Excel*/
%display IMPORT;
proc import datafile="&chemin"
out=mydata
dbms=excel
replace;
getnames=yes;
run;
%mend importation;
/*affichage de la table saisie sur le log*/
%macro affichage;
proc print data=mydata;
title "etude de &chemin";
run;
%mend affichage;
/*macro programme de chaque méthode*/
/********************************************/
/*exemple avec depart.xls*/
%macro acp;/* juste le princomp obligatoire*/
proc princomp data =mydata out =individu;
run;
/*réalisation du graphique*/
symbol pointlabel=("#&id");
proc gplot data=individu;
plot prin2*prin1 /href=0 vref=0;
run;
quit;
%mend acp;
%macro afc;/* var obligatoire*/
proc corresp data=mydata outc=tab;
var &id;/*ex:sepallon--fonction*/
run;
/*creation de la table d'annotation pour afficher les profils lignes et colonnes en deux couleurs differentes*/
data anno;
set tab;
x=dim1;
y=dim2;
xsys='2';
ysys='2';
text=&id;
run;
select (_type_);
when ('OBS') color='red';
when ('VAR') color='blue';
otherwise;
end;
run;
goptions reset=all;
proc gplot data=anno;
plot y*x / annotate=anno vref=0 href=0;
run;
quit;
%mend afc;
/*exemple avec iris.xls*/
%macro afd;/*class obligatoire*/
proc discrim data=mydata can out=sortie anova manova simple;
class &id;
run;
/*graph de l'AFD*/
goptions reset=all;
symbol1 v=plus i=none;
symbol2 v=dot i=none;
symbol3 v=+ i=none;
proc gplot data=sortie;
plot can2*can1=&id /vref=0 href=0 ;
run;
quit;
%mend afd;
/*macro pour grouper les trois méthodes*/
%macro realisation;
%display question;
%if (&rep=1) %then %acp;
%if (&rep=2) %then %afc;
%if (&rep=3) %then %afd;
%mend realisation
/*programme principale*/
%macro programme;
%do %until (&choix=4);
%display menu;
%let firstchoice=&choix;
%if((&firstchoice ne 1)&(&firstchoice ne 4)) %then %display nonsaisie;
%if &choix=1 %then %importation;
%else %if &choix=2 %then %affichage;
%else %if &choix=3 %then %realisation;
%end;
%mend programme;
%programme; |
Partager