The code first configures global graphics options. Then, it filters the `sashelp.class` table for each age (11 to 16 years old) to generate pie charts representing sex distribution. These charts are exported as local PNG files. Finally, these images are reused via `PATTERN` statements to fill the bars of a vertical histogram representing the ages.
Data Analysis
Type : SASHELP
Uses the standard `sashelp.class` table provided with SAS.
1 Code Block
GOPTIONS
Explanation : Resetting and configuring global graphics parameters (size, resolution, font, PNG output driver).
Explanation : Sequential generation of pie charts for each age group. Each chart is saved in a distinct PNG file specified by the `FILENAME` statement. Note: The 'c:\' paths are specific to Windows and will need to be adapted for a SAS Viya (Linux) environment.
Copied!
filename g 'c:\sex11.png' ; proc gchart data=sashelp.class ; where age=11 ; pie sex ; run ;
filename g 'c:\sex12.png' ; proc gchart data=sashelp.class ; where age=12 ; pie sex ; run ;
/* ... Répété pour les âges 13 à 16 ... */
filename g 'c:\sex16.png' ; proc gchart data=sashelp.class ; where age=16 ; pie sex ; run ;
1
filename g 'c:\sex11.png' ; PROC GCHARTDATA=sashelp.class ; where age=11 ; pie sex ; RUN ;
2
filename g 'c:\sex12.png' ; PROC GCHARTDATA=sashelp.class ; where age=12 ; pie sex ; RUN ;
3
/* ... Répété pour les âges 13 à 16 ... */
4
filename g 'c:\sex16.png' ; PROC GCHARTDATA=sashelp.class ; where age=16 ; pie sex ; RUN ;
3 Code Block
PROC GCHART
Explanation : Creation of the final chart (vertical histogram by age). The `PATTERN` statements map the previously generated PNG images to the chart bars. The `subgroup=age` option ensures that each bar uses the pattern corresponding to its age.
vbar age / subgroup=age discrete width=20 nolegend ;
11
RUN; QUIT;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.