<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How Can I Specify Line Colors per Group in SG Plot? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469547#M16166</link>
    <description>&lt;P&gt;Hi, there:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Submitting the following code, I got this result.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    input usubjid$ trta$ avisit$ aval;
    datalines;
    xx-01 A Day1 10
    xx-01 A Day5 11
    xx-02 A Day1  9
    xx-02 A Day5 10
    xx-03 B Day1 20
    xx-03 B Day5 17
    xx-04 B Day1 19
    xx-04 B Day5 21
    ;
run;
proc sgplot data=test;
    series x=avisit y=aval / group=usubjid;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20180612_1.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21165iD5F9B30DCB92919B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="20180612_1.JPG" alt="20180612_1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This result is displayed with different colors per subject (ex. Red for Subject XX-02),&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I want to specify colors per Variable TRTA (ex. if TRTA eq "A" then Red, in other words, Subject XX-01 &amp;amp; XX-02 are displayed with Red Line).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I surfed the net, but haven't found how to do it.&lt;/P&gt;&lt;P&gt;Please help me. Thank you in advance.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jun 2018 09:59:42 GMT</pubDate>
    <dc:creator>KentaMURANAKA</dc:creator>
    <dc:date>2018-06-12T09:59:42Z</dc:date>
    <item>
      <title>How Can I Specify Line Colors per Group in SG Plot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469547#M16166</link>
      <description>&lt;P&gt;Hi, there:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Submitting the following code, I got this result.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    input usubjid$ trta$ avisit$ aval;
    datalines;
    xx-01 A Day1 10
    xx-01 A Day5 11
    xx-02 A Day1  9
    xx-02 A Day5 10
    xx-03 B Day1 20
    xx-03 B Day5 17
    xx-04 B Day1 19
    xx-04 B Day5 21
    ;
run;
proc sgplot data=test;
    series x=avisit y=aval / group=usubjid;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20180612_1.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21165iD5F9B30DCB92919B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="20180612_1.JPG" alt="20180612_1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This result is displayed with different colors per subject (ex. Red for Subject XX-02),&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I want to specify colors per Variable TRTA (ex. if TRTA eq "A" then Red, in other words, Subject XX-01 &amp;amp; XX-02 are displayed with Red Line).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I surfed the net, but haven't found how to do it.&lt;/P&gt;&lt;P&gt;Please help me. Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 09:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469547#M16166</guid>
      <dc:creator>KentaMURANAKA</dc:creator>
      <dc:date>2018-06-12T09:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Specify Line Colors per Group in SG Plot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469557#M16167</link>
      <description>&lt;P&gt;It doesn't make sense.&amp;nbsp; If you have 10 subjects, 5 of which are in trta and 5 in trtb, and you color all the lines in red, then the legend will not help any reviewer as you will not be able to tell which subject is which as they will always be the same color.&amp;nbsp; So you either make the choice of displaying the data based on subject, or on treatment.&amp;nbsp; In my experience these tyeps of graphs are generally displayed by treatment, with all the lines in the treatment the same color, so you can see treatment effect difference.&amp;nbsp; So you would change&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;group=usubjid;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;group=trt;&lt;/PRE&gt;
&lt;P&gt;Alternatively if you need to see each usubjid, then you would keep the output as you have it.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 10:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469557#M16167</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-12T10:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Specify Line Colors per Group in SG Plot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469561#M16168</link>
      <description>&lt;P&gt;RW9:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your response.&lt;/P&gt;&lt;P&gt;I changed GROUP=USUBJID to GROUP=TRTA, and I got the following result.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20180612_2.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21166i089FF8365B9AAD3E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="20180612_2.JPG" alt="20180612_2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It has the lines I don't want. Do you know how to delete them?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 10:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469561#M16168</guid>
      <dc:creator>KentaMURANAKA</dc:creator>
      <dc:date>2018-06-12T10:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Specify Line Colors per Group in SG Plot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469576#M16169</link>
      <description>&lt;P&gt;It depends on what you want out.&amp;nbsp; You could for instance take a mean of the two groups and plot the mean, hence one line per treatment group.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find examples and code for any graph here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 11:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469576#M16169</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-12T11:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Specify Line Colors per Group in SG Plot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469619#M16171</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/204979"&gt;@KentaMURANAKA&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use line colors to distinguish between&amp;nbsp;treatment groups and line patterns to distinguish between patients within a treatment group. (Limitation: You may run out of line patterns if you have too many patients per group.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example using your dataset TEST:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myattrmap;
set test(keep=usubjid trta);
by trta usubjid;
if first.usubjid;
if first.trta then linepattern=1;
else linepattern+1;
if trta='A' then linecolor='Blue';
else if trta='B' then linecolor='Red';
id='myid';
rename usubjid=value;
run;

proc sgplot data=test dattrmap=myattrmap;
    series x=avisit y=aval / group=usubjid attrid=myid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result (maybe an additional legend regarding the groups should be inserted):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sgplot.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21167iC00C60094D8439AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="sgplot.PNG" alt="sgplot.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 13:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469619#M16171</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-06-12T13:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Specify Line Colors per Group in SG Plot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469806#M16177</link>
      <description>&lt;P&gt;Hi, FreelanceReinhard:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;Thanks to your advice, I accomplished my objective.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    input usubjid$ trta$ avisit$ aval;
    datalines;
    xx-01 A Day1 10
    xx-01 A Day5 11
    xx-02 A Day1  9
    xx-02 A Day5 10
    xx-03 B Day1 20
    xx-03 B Day5 17
    xx-04 B Day1 19
    xx-04 B Day5 21
    ;
run;
data myattrmap;
set test(keep=usubjid trta);
by trta usubjid;
if first.usubjid;
linepattern=1;
if trta='A' then linecolor='Blue';
else if trta='B' then linecolor='Red';
id='myid';
rename usubjid=value;
run;
proc sgplot data=test dattrmap=myattrmap noautolegend;
    series x=avisit y=aval / group=usubjid attrid=myid;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20180613_1.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21173i5284903EBC064BAE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="20180613_1.JPG" alt="20180613_1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot, All!!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 00:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-Can-I-Specify-Line-Colors-per-Group-in-SG-Plot/m-p/469806#M16177</guid>
      <dc:creator>KentaMURANAKA</dc:creator>
      <dc:date>2018-06-13T00:14:31Z</dc:date>
    </item>
  </channel>
</rss>

