BookmarkSubscribeRSS Feed
lueryy2000
Calcite | Level 5
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
2 REPLIES 2
NickR
Quartz | Level 8
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;
lueryy2000
Calcite | Level 5
Thank you very much. It works perfectly!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1508 views
  • 0 likes
  • 2 in conversation