BookmarkSubscribeRSS Feed
jrleighty
Fluorite | Level 6

I have a dataset with five variables I would like to use to display the data on a graph. The data is grouped by the first variable (p) and sub-grouped by the second variable (i) along the x-axis. The fourth variable (nor) determines the height of the point along the y-axis. The fifth variable (mnor) is the mean of the nor values for each subgroup.

 

I want to replace the circle with a unique symbol determined by the third variable (date), so that the graph is easier to interpret the results from different days the data was collected. I have been able to replace the point with the date but would prefer a symbol to minimize clutter. I've included a sample code below. The first graph is my original graph without including the date variable, and the second graph is replacing the points with the date value.

 

data samp;
	input p$ i date: date9. nor mnor;
	format date date9.;
	datalines;
	A 0 16May2024 1.230 1.000
	A 0 23May2024 0.770 1.000
	A 1 16May2024 0.014 0.021
	A 1 23May2024 0.028 0.021
	B 0 16May2024 1.576 1.504
	B 0 23May2024 1.432 1.504
	B 1 16May2024 0.064 0.071
	B 1 23May2024 0.078 0.071
	C 0 16May2024 0.432 0.510
	C 0 23May2024 0.588 0.510
	C 1 16May2024 0.011 0.009
	C 1 23May2024 0.007 0.009
	;

title "Example Graph 1";
proc sgplot data = samp noborder;
	scatter x = p y = nor /
		markerattrs = (symbol=CircleFilled) group = i  groupdisplay = cluster;
	highlow x = p low = mnor high = mnor / nofill type = bar barwidth = 0.4 group = i groupdisplay = cluster;
	xaxis type = discrete labelattrs = (size = 9) display = (nolabel);
	yaxis labelattrs = (size = 9) display = (nolabel) grid;
run;

title "Example Graph 2";
proc sgplot data = samp noborder;
	scatter x = p y = nor /
		markercharattrs = (weight = bold) markerchar = date group = i groupdisplay = cluster;
	highlow x = p low = mnor high = mnor / nofill type = bar barwidth = 0.4 group = i groupdisplay = cluster;
	xaxis type = discrete labelattrs = (size = 9) display = (nolabel);
	yaxis labelattrs = (size = 9) display = (nolabel) grid;
run;
2 REPLIES 2
ballardw
Super User

Can you post a link to a graph similar to what you want?

 

Does your "real" data have more than 2 dates involved?

 

I am having a hard time envisioning, given the data, the use at all. You have a highlow plot with the same variable for high and low which doesn't really make sense for the purpose behind high and low.

 

 

Rick_SAS
SAS Super FREQ

I cannot visualize what you are trying to do, but consider whether you need to use a second SCATTER statement to get the symbols that you need. The first SCATTER statement uses the GROUP= option, so the marker colors and symbols are tied to the group variable (i). You might need to structure the data differently and use a second scatter plot overlay to achieve your result.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 270 views
  • 0 likes
  • 3 in conversation