There are cleaner ways, but I have to run to a meeting, and this is the way I remember off of the top of my head. Your SAS/GRAPH statements have no effect on ODS Graphics.
data new;
input Year li ui;
v = 'v';
c = '^';
datalines;
2015 1200 1360
2014 1170 1330
2013 1170 1330
2012 1140 1330
2011 1130 1320
2010 1110 1310
2009 1140 1310
2008 1120 1290
2007 1130 1300
2006 1150 1310
;
ods html body='b.html';
proc sgplot data =new noautolegend;
scatter x=year y=li / markerchar=v;
scatter x=year y=ui / markerchar=c;
run;
ods html close;
I think you might enjoy reading a basic introduction to the SG (=statistical graphics) procedures. It will give you an understanding of how different statements work.
Warren,
I figured out the issue, my mistake and THANKS for your help.
proc sgplot data=new noautolegend nocycleattrs;
symbolchar char='2038'x name=c;
symbolchar char='0087'x name=v;
reg x=year y=li / cli clm nomarkers;
reg x=year y=ui / cli clm nomarkers;
scatter x=year y=li / markerchar=v;
scatter x=year y=ui / markerchar=c;
run;
It makes regression lines, confidence limits, prediction limits, and the special symbols that you want. Either you are using a really old SAS release that does not support the statements I provided, or I don't know what you want. Either way, I tested my code, and it does work. Rick gave you some references. I also suggest searches for the "SAS Graphically Speaking" blog and my basic book "Basic ODS Graphics Examples". Cheers.
Ask yourself why you got that message. Look at the data set. Are those variables there? Then what can you do? Was there a different version that has them there? I could tell you precisely what to do but if you are going to become a productive SAS user, you need to learn to carefully look at what is going on in your code.
I believe the variables c and v need to be added to the dataset but I am not sure about the right way of adding them.
I use this other code:
symbolchar char='2038'x;
symbolchar char='0087'x;
proc gplot data=new;
plot lq*year ;
plot2 uq*year ;
run;
quit;
I think I need y on x-axis and the two variables lq and uq on the y-axis.
I am not sure of intention with this code, but, the SCATTER statement should likely have MARKERATTRS=(SYMBOL=c).
Hi Sanjay,
The original question is I am trying to prepare a scatterplot with the lower quartile (lq) on the vertical axis versus the year on the horizontal axis and to mark these observations on the plot with the character v. Also on the same plot, I need to show the upper quartile (uq) plotted against the year and to mark these points with a ^. I am interested in showing confidence intervals or prediction intervals on a plot.
I used this code as you recommended:
data new;
input year lq uq;
datalines;
2015 1200 1360
2014 1170 1330
2013 1170 1330
2012 1140 1330
2011 1130 1320
2010 1110 1310
2009 1140 1310
2008 1120 1290
2007 1130 1300
2006 1150 1310
;
proc sgplot data=new noautolegend nocycleattrs;
symbolchar char='2038'x name=c;
symbolchar char='0087'x name=v;
reg x=year y=lq / cli clm nomarkers;
reg x=year y=uq / cli clm nomarkers;
scatter x=year y=lq / MARKERATTRS=(SYMBOL=c);
scatter x=year y=uq / MARKERATTRS=(SYMBOL=v);
run;
It runs but I still did not get the symbol charater ^ or v for either variable. And the uq does not appear on the y-axis?
This works with my SAS 9.40M3 version. Should work with any SAS 9.4. I used Microsoft's Character map app to find the encoding for the characters you want. I also increased the marker size as the characters occupy only a small part of the character space. Note, with characters, the center of the character bounding box will go at the (x, y) location. So, if your character is offset, "v" is likely offset down, and "^" is likely offset up, you will get them off the (x, y) value a bit. You can use the options on the SYMBOLCHAR statement (hoffset, voffset, rotate, scale) to position them correctly. You can increase the SIZE option to see them more clearly.
proc sgplot data=new noautolegend nocycleattrs;
symbolchar char='005e'x name=c;
symbolchar char='0076'x name=v;
reg x=year y=lq / cli clm nomarkers;
reg x=year y=uq / cli clm nomarkers;
scatter x=year y=lq / MARKERATTRS=(SYMBOL=c size=30);
scatter x=year y=uq / MARKERATTRS=(SYMBOL=v size=25);
run;
You really only need:
proc sgplot data=new noautolegend nocycleattrs;
symbolchar char='005e'x name=c;
symbolchar char='0076'x name=v;
reg x=year y=lq / cli clm MARKERATTRS=(SYMBOL=c size=30);
reg x=year y=uq / cli clm MARKERATTRS=(SYMBOL=v size=25);
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.