BookmarkSubscribeRSS Feed
ocdobv
Calcite | Level 5

Hello.  I'm relatively new to SAS graphing and am learning by trial and error.

How can I produce a plot that shows the major gridlines in gray (as shown in code 1) as well as show some particular reference lines in different colors (as shown in code 2)?

code1:

proc gplot data=sashelp.class;

plot height*weight /

haxis=axis1

vaxis=axis2

autovref cvref=graydd;

run;

code2:

proc gplot data=sashelp.class;

plot height*weight /

haxis=axis1

vaxis=axis2

vref=(63 68 74)

cvref=(green yellow red);

run;

Thanks.

5 REPLIES 5
Jay54
Meteorite | Level 14

Very easy with SGPLOT:

sgplot data=sashelp.class;

  scatter x=weight y=height;

  refline 63 68 74 / noclip lineattrs=(pattern=dash);

  yaxis grid;

  run;

If you want each refline colored differently, use three separate refline statements with three different colors.

ocdobv
Calcite | Level 5

Thank you.   This opens up lots of new things for me to try Smiley Wink

GraphGuy
Meteorite | Level 14

Similarly easy with gplot ...

proc gplot data=sashelp.class;

plot height*weight /

haxis=axis1

vaxis=axis2

vref=(50 60 63 68 70 74 80)

cvref=(graydd graydd green yellow graydd red graydd);

run;

ocdobv
Calcite | Level 5

This works perfectly for the example I provided.   Is there any way to auto generate the 50, 60, 70, 80  --- similar to how the autoref does it? 

It's probably not a big deal.  I just don't like typing graydd 20+ times to account for different possible datasets.

GraphGuy
Meteorite | Level 14

Sometimes I use autoref for the gray lines, and then annotate the 'special' (colored) lines.

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!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1789 views
  • 6 likes
  • 3 in conversation