Quartz | Level 8

Plotting vertical lines and representing percentage values in graph

Hi All,
I have got one reference  graph to create similar output (attached is the graph) , but not sure what type of graphs is it.(assuming it as scatter plot, not sure) . As per the attached graph values on X- axis represents each state code(numeric value) and the y-axis values are percentage of cars present in each state (two different companies X and Y). May i know how the 0% values are represented on above x-axis and vertical lines from 0 to the respective percentages or sometimes the corresponding percentage is in between. Colour represents companies X and Y.
Any sample code/suggestions how to generate this and what this graph is called. Thanks in advance for suggestions

4 REPLIES 4
Super User

Re: Plotting vertical lines and representing percentage values in graph

No idea what it's called but you could create it with a Scatter statement and error bars that have dotted lines.
You could also do two scatter statements and a drop line most likely.

SGPLOT would be where you would start and I'd assume you're starting with aggregate data already.
SAS Super FREQ

Re: Plotting vertical lines and representing percentage values in graph

If I were creating this using SGPLOT, here is how I would do it (this following code is just a guideline):

``````proc sgplot data=wahtever;
refine 25 / lineattrs=(pattern=dot color=red);
refine 13 / lineattrs=(pattern=dot color=black);
highlow x=xvar high=highvar low=lowvar / lineattrs=(pattern=dot color=lightgray);
scatter x=xvar y=highvar / markerattrs=(symbol=circlefilled color=red);
scatter x=xvar y=lowvar / markerattrs=(symbol=square color=black);
text x=xvar y=highvar text=highpct / textattrs=(color=red) position=top pad=(bottom=3px);
text x=xvar y=lowvar text=lowpct / textattrs=(color=black) position=top pad=(bottom=3px);
run;``````

SAS Super FREQ

Re: Plotting vertical lines and representing percentage values in graph

You will probably need this statement inside SGPLOT as well (given your data):

xaxis type=discrete;

SAS Super FREQ

Re: Plotting vertical lines and representing percentage values in graph

I would call this graph a (vertical) high-low plot. For an overview, see this blog post. For more details about the vertical high-low plot, see "Getting started with SGPLOT: Vertical HighLow Plot."

Discussion stats
• 4 replies
• 259 views
• 2 likes
• 4 in conversation