How to plot five variables using Proc SGplot and the Scatter statement(s)?
var1: x
var2: y
var3: group
var4: markerchar?
var5: ?
Ideally, I would like to vary the symbol, symbol size, and symbol color on each figure.
I'm using 9.4, SAS/STAT 15.1.
If you have 5 separate variables you can include 5 series statements and control the symbols/colours in the statement.
Example with two lines here
https://robslink.com/SAS/ods2/sct1_info.htm
Another option is discrete attribute maps, for each variable you'll specify the symbol, colour, thickness etc in a data set and then pass that to the procedure.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n18szqcwir8q2nn10od9hhdh2ksj.htm
@BayesBeatsFreqs wrote:
How to plot five variables using Proc SGplot and the Scatter statement(s)?
var1: x
var2: y
var3: group
var4: markerchar?
var5: ?
Ideally, I would like to vary the symbol, symbol size, and symbol color on each figure.
I'm using 9.4, SAS/STAT 15.1.
If you have 5 separate variables you can include 5 series statements and control the symbols/colours in the statement.
Example with two lines here
https://robslink.com/SAS/ods2/sct1_info.htm
Another option is discrete attribute maps, for each variable you'll specify the symbol, colour, thickness etc in a data set and then pass that to the procedure.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n18szqcwir8q2nn10od9hhdh2ksj.htm
@BayesBeatsFreqs wrote:
How to plot five variables using Proc SGplot and the Scatter statement(s)?
var1: x
var2: y
var3: group
var4: markerchar?
var5: ?
Ideally, I would like to vary the symbol, symbol size, and symbol color on each figure.
I'm using 9.4, SAS/STAT 15.1.
@BayesBeatsFreqs wrote:
How to plot five variables using Proc SGplot and the Scatter statement(s)?
var1: x
var2: y
var3: group
var4: markerchar?
var5: ?
Ideally, I would like to vary the symbol, symbol size, and symbol color on each figure.
I'm using 9.4, SAS/STAT 15.1.
From this description, I don't really have a good idea of what the resulting plot would look like. I also don't know how "var5: ?" should be interpreted.
What is var5 supposed to be used for? A question mark doesn't provide much help.
By default the Value of group is used to assign Marker appearance but the option Markerchar=variable can be used. Example with a data set you should have.
proc sgplot data=sashelp.class; scatter x=height y=weight/ markerchar=name; run;
If you have a Group variable such as:
proc sgplot data=sashelp.class; scatter x=height y=weight/group=age markerchar=name; run;
the values of the group variable will set some marker attributes, mostly color but possibly size of text.
You should provide some explicit descriptions of exactly what you want to control and the rules involved.
The DATTRMAP optional data set can be used to address GROUP variable appearance which would include settings for markers such as marker size, symbol, color, transparency.
The DATTRMAP may be the best way to control consistency across multiple graphs.
Can't offer any more info. It was just a general question prompted by something I read. thanks.
How about six variables on one plot? Here's what has been called the best statistical plot ever made: a drawing of Napoleon's campaign into Russia in 1812. https://bigthink.com/strange-maps/229-vital-statistics-of-a-deadly-campaign-the-minard-map/
@BayesBeatsFreqs wrote:
Ok, more detail: var1 and var2 are continuous, and var3-var5 are categorical with lets say two levels each, so a total of eight groups. How to show all eight groups on one figure? Each variable (var3-var5) should be identified by one of the following: symbol, symbol size, symbol color.
Proc sgplot will allow multiple plots to overlay on a single graph. Mixing some types is limited and may require you to modify your data bit depending what type of display you want for categorical. To display Scatter, series or similar plots with "categorical" really depends on what you want as there are limits at to what can be displayed on a single plot together.
Show you need to show what you might want or perhaps wonder around here to look at examples with data and code from multiple procedures: https://support.sas.com/en/knowledge-base/graph-samples-gallery.html
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.