The data is directly integrated into the script via a DATA statement with CARDS, creating the temporary 'auto' dataset.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates a temporary SAS dataset named 'auto'. Data is read in-line using the CARDS statement and defines the variables 'make' (character), 'mpg', 'rep78', 'weight1', and 'foreign1' (numeric). 'mpg' represents fuel consumption, 'weight1' is weight, and 'foreign1' indicates whether the car is foreign (1) or not (0).
Explanation : This procedure generates a frequency table for the 'mpg' variable from the 'auto' dataset. It allows observing the distribution of different fuel consumption values.
Copied!
PROC FREQ DATA = auto;
TABLES mpg;
RUN;
1
PROC FREQDATA = auto;
2
TABLES mpg;
3
RUN;
3 Code Block
GOPTIONS
Explanation : This statement resets all global graphic options to their default values and adds a border to the generated graphs. This ensures a clean base for subsequent graphs.
Copied!
goptions reset=all border;
1
goptions reset=all border;
4 Code Block
PROC PLOT
Explanation : This procedure generates a simple scatter plot ('plot') of 'mpg' (Y-axis) versus 'weight1' (X-axis) from the 'auto' dataset. It provides an initial visual overview of the relationship between these two variables.
Copied!
proc plot data=auto;
plot mpg * weight1 ;
run;
1
2
PROC PLOT
3
DATA=auto;
4
plot mpg * weight1 ;
5
6
RUN;
7
5 Code Block
PROC GPLOT
Explanation : This procedure generates a more elaborate GPLOT graph. The title 'Study of MPG vs Weight' is set. The SYMBOL statement configures the display of points and the regression line (interpol=rqcli95 for a quadratic regression with 95% confidence intervals, points as circles, specific colors). The graph represents 'mpg' as a function of 'weight1', with points colored differently according to the 'foreign1' variable. The X and Y axes are customized with specific ranges and increments, and the 'regeqn' option displays the regression equation on the graph.
Copied!
proc gplot data=auto;
title "Study of MPG vs Weight";
symbol interpol= rqcli95
value=circle
cv= crimson
ci = black
co = bib
width= 2
;
plot mpg*weight1 = foreign1 / haxis=2000 to 4500 by 500
vaxis=12 to 35 by 2
regeqn;
run;
1
PROC GPLOTDATA=auto;
2
title "Study of MPG vs Weight";
3
4
symbol interpol= rqcli95
5
value=circle
6
cv= crimson
7
ci = black
8
co = bib
9
width= 2
10
;
11
12
plot mpg*weight1 = foreign1 / haxis=2000 to 4500BY500
13
vaxis=12 to 35BY2
14
regeqn;
15
16
RUN;
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.
Copyright Info : Author - Anupama Rajaram Program Description - This program creates a simple gplot of 2 variables, draws the plot line and calculates regression equation. y-axis = mpg. x-axis = weight1.
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.