plot - SAS:如何在基于二进制变量的绘图中使用不同的符号

标签 plot sas

我正在尝试绘制如下所示的数据:

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;

产生这个: enter image description here

关于plot - SAS:如何在基于二进制变量的绘图中使用不同的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18879205/

相关文章:

r - 在R中绘制正态,左右偏斜分布

python - 在 matplotlib 中设置分组条形图之间的间距

python - Python 中的 4 个子图条形图

arrays - 在 SAS 中使用数组

r - 更改马尔可夫链图中箭头的大小

python - 删除 matplotlib 图中的 xticks?

sas - 将 *most* 变量设置为缺失,同时保留少数几个的内容

sas - 过程 SQL : How/When does SAS Move the Data

sas - 在 SAS 中对变量执行测试

SAS 宏的 REST 端点?