BookmarkSubscribeRSS Feed
echoli
Obsidian | Level 7

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:

timepoint1timepoint2age_1age_2GroupID
75.74531557.56403915.817TX14468
62.84454261.2603615.116.1TX15597
40.13480140.7988979.210.3TX21016
34.01227335.61295111.112TX21834
46.0228743.0878513.614.7TX21838
50.71742338.30584416.117.2TX22596
68.01973660.62485217.318.4TX22637
54.97947155.7466817.28.5TX22784
43.69754854.66064810.512TX23137
43.63086228.94710717.819.1TX24425
34.54333446.7470187.58.5TX25227
51.69235747.31392813.914.9TX29840
37.64390440.63724512.413.4TX36828
33.42766942.48485812.213.2TX37255
51.06486946.9040048.69.5TX38459
50.1548.92077713.714.7TX38904
32.29079138.3933359.310.2TX41404
38.22193849.3459114.315.3cont21746
30.75346127.8965517.69cont22344
42.52394838.6366361213.1cont22504
68.74064164.17510211.612.6cont23026
46.08366350.0199891415cont23111
72.16842245.67053411.112.1cont24089
46.03624350.3016812.813.8cont24336
80.43334777.73657516.617.6cont25996
56.22556633.9836888.79.7cont26438

 

Thanks,

C

7 REPLIES 7
Reeza
Super User

Have you looked at STYLEATTRS statement (first in SGPLOT documentation) or an Attribute Map?

 

This is old, but I think it's still valid:

 

http://blogs.sas.com/content/iml/2012/10/17/specify-the-colors-of-groups-in-sas-statistical-graphics...

Rick_SAS
SAS Super FREQ

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

echoli
Obsidian | Level 7
Hi Rick,
Yes, 1,2,3,4 are the four lines I want. I want four lines with four different colors. In my picture, 1 and 2 have the same color, 3 and 4 have the same color. That's what I want to solve.

Thanks,
C
Rick_SAS
SAS Super FREQ

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?

echoli
Obsidian | Level 7
Hi Rick,

In my picture, there are four kinds of data points, matched with 1, 2, 3, 4 you helped me list in the reply. I want four colors for these four kinds of data points, and also four lines matched with same colors.
Like in the vector statement, I want X, Y, Xorigin, Yorigin have different colors, is that possible? Also, the four lines create by X, Y, xorigin, yorigin columns in Loess statement should match same colors as vector statement.
Is my explain clear?
Thanks so much for your patience to help me!

C
DanH_sas
SAS Super FREQ

Try specifying CYCLEATTRS on the SGPLOT procedure statement and see if that gives you what you want.

 

Hope this helps!

Dan

Rick_SAS
SAS Super FREQ

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

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
  • 7 replies
  • 3685 views
  • 0 likes
  • 4 in conversation