Le script utilise exclusivement le jeu de données `sashelp.class` comme source de données d'entrée pour toutes les analyses et générations de graphiques.
1 Bloc de code
PROC REPORT
Explication : Configure la sortie des procédures vers un fichier texte nommé `ch10_3_2.txt` à l'aide de `PROC PRINTTO` et `FILENAME`. Génère ensuite un rapport formaté à partir du jeu de données `sashelp.class` en utilisant `PROC REPORT`.
Copié !
* S10_3_2.sas
*
* combining REPORT tables and graphics;
odS listing;
goptions reset=all;
filename textrpt "&path/results/ch10_3_2.txt";
proc printto print=textrpt new;
run;
title1;
proc report data=sashelp.class nowd;
column sex age height weight;
define sex / group 'Gender' format=$6.;
define age / group "Age" width=3;
define height / mean 'Height' format=6.1;
define weight / mean 'Weight' format=6.2;
break after sex / skip summarize suppress;
run;
proc printto;
run;
1
* S10_3_2.sas
2
*
3
* combining REPORT tables and graphics;
4
5
odS listing;
6
goptions reset=all;
7
8
filename textrpt "&path/results/ch10_3_2.txt";
9
10
PROC PRINTTOPRINT=textrpt new;
11
RUN;
12
13
title1;
14
PROC REPORTDATA=sashelp.class nowd;
15
column sex age height weight;
16
define sex / group 'Gender'FORMAT=$6.;
17
define age / group "Age" width=3;
18
define height / mean 'Height'FORMAT=6.1;
19
define weight / mean 'Weight'FORMAT=6.2;
20
break after sex / skip summarize suppress;
21
RUN;
22
23
PROC PRINTTO;
24
RUN;
25
2 Bloc de code
PROC GPRINT
Explication : Nettoie les catalogues graphiques temporaires avec `PROC DATASETS`. Importe le rapport texte généré précédemment dans SAS/GRAPH sous le nom `classrpt` avec `PROC GPRINT`. Définit les options graphiques et crée une diapositive de titre avec `PROC GSLIDE`.
Copié !
* Clear the GSEG catalog from the work library;
proc datasets library=work mt=cat nolist;
delete gseg;
quit;
goptions ftext=simplexu htext=1.8;
* Import the table into SAS/GRAPH;
proc gprint fileref=textrpt name='classrpt';
run;
goptions ftext=swiss htext=2;
* create the TITLE;
proc gslide name='Slide';
title1 'Interfacing with REPORT';
title2 h=1.5 'Rendering a Report with SAS/GRAPH';
run;
1
* Clear the GSEG catalog from the work library;
2
PROC DATASETS library=work mt=cat nolist;
3
delete gseg;
4
QUIT;
5
6
goptions ftext=simplexu htext=1.8;
7
8
* Import the table into SAS/GRAPH;
9
PROC GPRINT fileref=textrpt name='classrpt';
10
RUN;
11
12
13
goptions ftext=swiss htext=2;
14
15
* create the TITLE;
16
PROC GSLIDE name='Slide';
17
title1 'Interfacing with REPORT';
18
title2 h=1.5'Rendering a Report with SAS/GRAPH';
19
RUN;
20
3 Bloc de code
DATA STEP Data
Explication : Crée un nouveau jeu de données `class` basé sur `sashelp.class`, en modifiant légèrement la variable `age` pour différencier visuellement les sexes. Utilise `PROC GPLOT` pour générer trois graphiques de dispersion : `height` vs `age`, `weight` vs `age`, et `weight` vs `height`, en utilisant le sexe pour la distinction visuelle.
Copié !
symbol1 c=red value=dot i=stdm2j l=33;
symbol2 c=blue value=square i=stdm2j l=1;
data class;
set sashelp.class;
* Separate gender in the plots;
age = age + (sex='F')*.05 + (sex='M')*-.05;
run;
* Create a scatter plot;
proc gplot data=class;
plot height*age=sex/name='height';
title1 'Height';
run;
plot weight*age=sex/name='weight';
title1 'Weight';
run;
symbol1 c=red value=dot i=none;
symbol2 c=blue value=square i=none;
plot weight*height=sex/name='w_h';
title1 'Weight vs Height';
run;
quit;
1
symbol1 c=red value=dot i=stdm2j l=33;
2
symbol2 c=blue value=square i=stdm2j l=1;
3
4
DATA class;
5
SET sashelp.class;
6
* Separate gender in the plots;
7
age = age + (sex='F')*.05 + (sex='M')*-.05;
8
RUN;
9
10
* Create a scatter plot;
11
PROC GPLOTDATA=class;
12
plot height*age=sex/name='height';
13
title1 'Height';
14
RUN;
15
plot weight*age=sex/name='weight';
16
title1 'Weight';
17
RUN;
18
symbol1 c=red value=dot i=none;
19
symbol2 c=blue value=square i=none;
20
plot weight*height=sex/name='w_h';
21
title1 'Weight vs Height';
22
RUN;
23
QUIT;
24
4 Bloc de code
PROC GREPLAY
Explication : Configure le périphérique graphique pour générer un fichier GIF nommé `ch10_3_2.gif`. Utilise `PROC GREPLAY` pour assembler plusieurs éléments graphiques et le rapport texte (représentés par les graphiques `Slide`, `height`, `w_h`, `weight` et l'objet `classrpt`) dans une mise en page définie par le modèle `three_t`.
* Build a template and replay the graphs and table;
7
PROC GREPLAY igout=gseg nofs tc=gtempl8;
8
tdef three_t
9
1/ ulx=0 uly=100 urx=100 ury=100
10
llx=0 lly= 0 lrx=100 lry= 0
11
2/ ulx=0 uly=90 urx=50 ury=90
12
llx=0 lly=45 lrx=50 lry=45
13
3/ ulx=50 uly=90 urx=100 ury=90
14
llx=50 lly=45 lrx=100 lry=45
15
4/ ulx=0 uly=40 urx=50 ury=40
16
llx=0 lly= 0 lrx=50 lry= 0
17
5/ ulx=50 uly=40 urx=100 ury=40
18
llx=50 lly= 0 lrx=100 lry= 0;
19
template three_t;
20
treplay 1:Slide
21
2:height
22
3:w_h
23
4:weight
24
5:classrpt;
25
RUN;
26
QUIT;
27
Ce matériel est fourni "tel quel" par We Are Cas. Il n'y a aucune garantie, expresse ou implicite, quant à la qualité marchande ou à l'adéquation à un usage particulier concernant le matériel ou le code contenu dans les présentes. We Are Cas n'est pas responsable des erreurs dans ce matériel tel qu'il existe maintenant ou existera, et We Are Cas ne fournit pas de support technique pour celui-ci.
« Ce script est un exemple classique et puissant de "Legacy SAS/GRAPH". Il démontre comment transformer un simple rapport tabulaire en une planche graphique composite (un dashboard avant l'heure), en fusionnant du texte et des images au sein d'un même fichier. »
SAS et tous les autres noms de produits ou de services de SAS Institute Inc. sont des marques déposées ou des marques de commerce de SAS Institute Inc. aux États-Unis et dans d'autres pays. ® indique un enregistrement aux États-Unis. WeAreCAS est un site communautaire indépendant et n'est pas affilié à SAS Institute Inc.
Ce site utilise des cookies techniques et analytiques pour améliorer votre expérience.
En savoir plus.