Hi All,
I'm trying to draw figures with lines shown in the attachment file. As you can see, there are four lines totally, Two red lines represents CONT group, timepoint1 and timepoint2, seperately, but I want these two lines with different colors.
The same problem with TX group (two blue lines). I tried to use series statement, but that doesn't work. Any clues or idea?
Here is my code:
proc sgplot data=want;
loess x = age_1 y = timepoint1 / group = group interpolation = cubic degree = 2;
loess x = age_2 y = timepoint2 / group = group interpolation = cubic degree = 2;
scatter x = age_1 y = timepoint1 / group = group markerattrs = (symbol = SquareFilled );
scatter x = age_2 y = timepoint2 / group = group markerattrs = (symbol = CircleFilled);
vector x = age_2 y = timepoint2 / xorigin = age_1 yorigin = timepoint1 group = group arrowheadshape = filled;
xaxis label="Age" labelattrs = (size = 12);
yaxis label="Result" labelattrs = (size = 12);
run;
Here is my dataset:
timepoint1 | timepoint2 | age_1 | age_2 | Group | ID |
75.745315 | 57.564039 | 15.8 | 17 | TX | 14468 |
62.844542 | 61.26036 | 15.1 | 16.1 | TX | 15597 |
40.134801 | 40.798897 | 9.2 | 10.3 | TX | 21016 |
34.012273 | 35.612951 | 11.1 | 12 | TX | 21834 |
46.02287 | 43.08785 | 13.6 | 14.7 | TX | 21838 |
50.717423 | 38.305844 | 16.1 | 17.2 | TX | 22596 |
68.019736 | 60.624852 | 17.3 | 18.4 | TX | 22637 |
54.979471 | 55.746681 | 7.2 | 8.5 | TX | 22784 |
43.697548 | 54.660648 | 10.5 | 12 | TX | 23137 |
43.630862 | 28.947107 | 17.8 | 19.1 | TX | 24425 |
34.543334 | 46.747018 | 7.5 | 8.5 | TX | 25227 |
51.692357 | 47.313928 | 13.9 | 14.9 | TX | 29840 |
37.643904 | 40.637245 | 12.4 | 13.4 | TX | 36828 |
33.427669 | 42.484858 | 12.2 | 13.2 | TX | 37255 |
51.064869 | 46.904004 | 8.6 | 9.5 | TX | 38459 |
50.15 | 48.920777 | 13.7 | 14.7 | TX | 38904 |
32.290791 | 38.393335 | 9.3 | 10.2 | TX | 41404 |
38.221938 | 49.34591 | 14.3 | 15.3 | cont | 21746 |
30.753461 | 27.896551 | 7.6 | 9 | cont | 22344 |
42.523948 | 38.636636 | 12 | 13.1 | cont | 22504 |
68.740641 | 64.175102 | 11.6 | 12.6 | cont | 23026 |
46.083663 | 50.019989 | 14 | 15 | cont | 23111 |
72.168422 | 45.670534 | 11.1 | 12.1 | cont | 24089 |
46.036243 | 50.30168 | 12.8 | 13.8 | cont | 24336 |
80.433347 | 77.736575 | 16.6 | 17.6 | cont | 25996 |
56.225566 | 33.983688 | 8.7 | 9.7 | cont | 26438 |
Thanks,
C
Have you looked at STYLEATTRS statement (first in SGPLOT documentation) or an Attribute Map?
This is old, but I think it's still valid:
First, you can delete the SCATTER statements because the LOESS statements draw the markers. (Move the MARKERATTRS= option into the LOESS statement to control the marker attributes.)
I don't understand your question. What colors do you want for each line?
1. Y=TimePoint1, group=TX
2. Y=TimePoint1, group=cont
3. Y=TimePoint2, group=TX
4. Y=TimePoint2, group=cont
And do you want colors that are in any way related to the red/blue colors of the VECTOR plot? Or do you want different colors, such as purple, green, gold, and black?
Try specifying CYCLEATTRS on the SGPLOT procedure statement and see if that gives you what you want.
Hope this helps!
Dan
First, you can delete the SCATTER statements because the LOESS statements draw the markers. (Move the MARKERATTRS= option into the LOESS statement to control the marker attributes.)
I don't understand your question. What colors do you want for each line?
1. Y=TimePoint1, group=TX
2. Y=TimePoint1, group=cont
3. Y=TimePoint2, group=TX
4. Y=TimePoint2, group=cont
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.