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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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