The script begins by creating an internal dataset 'zodiacs' containing zodiac sign names and their respective frequencies. Then, it defines a custom format 'zodiacSymbol' that associates each sign with its corresponding Unicode symbol. A STATGRAPH template, 'unicodeUDF', is then created to specify the structure of a bar chart where the X-axis labels will use this Unicode format. Finally, PROC SGRENDER is used to produce the graph based on the defined template and 'zodiacs' data, also formatting the frequency variable as percentages for better readability.
Data Analysis
Type : CREATION_INTERNE
The data used ('zodiacs') is created directly within the SAS script via a DATA step and the DATALINES statement, meaning it is internal to the script and does not come from an external source.
1 Code Block
DATA STEP Data
Explanation : This block creates the 'zodiacs' dataset. It defines the 'Sign' variable as a 12-character string and 'Frequency' as a number. The data is then read from the datalines directly integrated into the script.
Explanation : This block uses PROC FORMAT to define a user-defined format named '$zodiacSymbol'. This format is essential for mapping each zodiac sign to its corresponding Unicode symbol. This allows graphic symbols to be displayed directly on the chart axis.
Explanation : This block defines a STATGRAPH template called 'unicodeUDF'. It configures a bar chart (barChartParm) with a title. The crucial option is 'xAxisOpts', which uses the '$zodiacSymbol' format defined previously to display Unicode symbols on the X-axis, thereby enhancing the visualization of categories.
Explanation : This block uses PROC SGRENDER to generate the chart based on the 'unicodeUDF' template and the 'zodiacs' dataset. The 'format Frequency percent.' statement applies a percentage format to the 'Frequency' variable, making the values more intuitive in the graph.
Copied!
proc sgrender template=unicodeUDF data=zodiacs;
format Frequency percent. ;
run;
1
2
PROC SGRENDER template=unicodeUDF
3
DATA=zodiacs;
4
FORMAT Frequency percent. ;
5
RUN;
6
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.