我正在尝试绘制如下所示的数据:
Year Test Mark
2000 98 0
2001 70 1
2002 80 0
2003 79 0
2004 80 0
2005 75 1
2006 77 1
2007 85 0
2008 90 0
2009 97 0
2010 90 0
2011 98 0
2012 96 0
2013 94 0
我想在 x 轴上绘制年份,在 y 轴上绘制测试分数,能够将这些点连接在一起并为二进制“标记”变量使用不同的符号:0 和 1。
哪个 proc 程序可以让我这样做?
最佳答案
将 PROC SGPLOT 与数据属性映射 (dattrmap=) 数据集结合使用。指定一个散点图来绘制点,并使用一个系列图来连接它们。
data toPlot;
format Year Test best. Mark 1.;
input Year Test Mark ;
datalines;
2000 98 0
2001 70 1
2002 80 0
2003 79 0
2004 80 0
2005 75 1
2006 77 1
2007 85 0
2008 90 0
2009 97 0
2010 90 0
2011 98 0
2012 96 0
2013 94 0
;;
run;
/*Set the marker attrib (astrisk=0 circle=1)*/
data plotattr;
format ID $8.
VALUE 1.
markersymbol markercolor $32.;
input ID VALUE markersymbol $ markercolor $;
datalines;
abc 0 asterisk red
abc 1 circle green
;;
run;
ods html;
proc sgplot data=toPlot dattrmap=plotattr;
series x=year y=test;
scatter x=year y=test / group=mark attrid=abc;
run;
ods html close;
产生这个:
关于plot - SAS:如何在基于二进制变量的绘图中使用不同的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18879205/