Published on :
Visualization CREATION_INTERNE

Random Data Generation and SGPLOT Visualization

This code is also available in: Deutsch Español Français
Awaiting validation
This program uses a DATA step to generate a dataset of 100 observations following a normal distribution. It then uses the SGPLOT procedure to display this data in a scatter plot with custom markers (4mm stars).
Data Analysis

Type : CREATION_INTERNE


Data is entirely generated in the DATA step via the RAND function.

1 Code Block
DATA STEP Data
Explanation :
Creation of a temporary table 'random_norm'. Use of 'CALL streaminit' for reproducibility and a DO loop to generate 100 observations where 'y' follows a standard normal distribution.
Copied!
1/* Generate some random data with group variable*/
2DATA random_norm;
3 CALL streaminit(585);
4 DO x = 1 to 100;
5 y = rand("Normal");
6 OUTPUT;
7 END;
8RUN;
2 Code Block
PROC SGPLOT
Explanation :
Generation of a Scatter Plot from the created data. The MARKERATTRS option is used to define the symbol (star) and size of the points.
Copied!
1/* Modify points of scatterplot with MARKERATTRS= */
2PROC SGPLOT DATA = random_norm;
3 SCATTER X=x Y=y / MARKERATTRS = (SYMBOL = STAR SIZE = 4MM);
4 TITLE "MARKERATTRS options";
5RUN;
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.