BookmarkSubscribeRSS Feed
keen_sas
Quartz | Level 8

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
Reeza
Super User
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.
DanH_sas
SAS Super FREQ

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;

 

 

DanH_sas
SAS Super FREQ

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

xaxis type=discrete;

Rick_SAS
SAS Super FREQ

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."

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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