Data visualization with SAS programming

How to draw a line to represent the difference

Reply
Contributor
Posts: 49

How to draw a line to represent the difference

Hi,

I have some data which I want to plot the difference between test1 and test2. Below is my data
ID test1 test2
1 7 7
2 4 5
3 13 16
4 12 14
5 5 6
6 13 16
7 12 10
8 18 20
9 16 16
10 11 12
11 14 15
12 11 11
13 16 17
14 18 16
15 14 15
16 17 18

First, I get a scatterplot of test1 and test2. To make the difference clearer, I want to draw a line to represent the difference. For example, for ID 2, test1=4, test2=5, my code only give two points at 4 and 5, and I also want to connect 4 and 5. Can anybody help me with this? Here is my code:

symbol1 v=diamond i=none c=blue l=1.2;
symbol3 v=triangle i=none c=red l=1.2;
proc gplot data=mydata;
plot (test1 test2)*ID / overlay;
run;
quit;

Thanks very much,
Lu
Frequent Contributor
Posts: 81

Re: How to draw a line to represent the difference

You can try using annotated dataset.

data ant;
set mydata;
length function color $8;
retain xsys ysys '2' hsys '3';
function='move'; x=id; y=test1; output;
function='draw'; color='black'; line=1; size=0.2; x=id; y=test2; output;
run;

symbol1 v=diamond i=none c=blue l=1.2;
symbol3 v=triangle i=none c=red l=1.2;
proc gplot data=mydata;
plot (test1 test2)*ID / overlay annotate=ant;
run;
quit;
Contributor
Posts: 49

Re: How to draw a line to represent the difference

Thank you very much. It works perfectly!
Post a Question
Discussion Stats
  • 2 replies
  • 82 views
  • 0 likes
  • 2 in conversation