<?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 I want to change color and pattern after a certain visit in proc sgplot ? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907466#M24261</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dsam_1-1702356258901.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/91199iAFB483780266CBD9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dsam_1-1702356258901.png" alt="dsam_1-1702356258901.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How do i display colors as below (&amp;nbsp; ihave attached my data and sample code where I am plotting median and p25 p75 stats values in this plot :&lt;/P&gt;&lt;P&gt;for res variable&amp;nbsp; R-R - show green color solid until Ebase visit and green color dash line from Ebase to Ewk38&lt;/P&gt;&lt;P&gt;R-NR - show green color solid until Ebase visit and red color dash line from Ebase to Ewk38&lt;/P&gt;&lt;P&gt;NR-R - show red color solid until Ebase visit and green color dash line from Ebase to Ewk38&lt;/P&gt;&lt;P&gt;NR-NR - show redcolor solid until Ebase visit and redcolor dash line from Ebase to Ewk38&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2023 04:47:49 GMT</pubDate>
    <dc:creator>dsam</dc:creator>
    <dc:date>2023-12-12T04:47:49Z</dc:date>
    <item>
      <title>I want to change color and pattern after a certain visit in proc sgplot ?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907466#M24261</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dsam_1-1702356258901.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/91199iAFB483780266CBD9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dsam_1-1702356258901.png" alt="dsam_1-1702356258901.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How do i display colors as below (&amp;nbsp; ihave attached my data and sample code where I am plotting median and p25 p75 stats values in this plot :&lt;/P&gt;&lt;P&gt;for res variable&amp;nbsp; R-R - show green color solid until Ebase visit and green color dash line from Ebase to Ewk38&lt;/P&gt;&lt;P&gt;R-NR - show green color solid until Ebase visit and red color dash line from Ebase to Ewk38&lt;/P&gt;&lt;P&gt;NR-R - show red color solid until Ebase visit and green color dash line from Ebase to Ewk38&lt;/P&gt;&lt;P&gt;NR-NR - show redcolor solid until Ebase visit and redcolor dash line from Ebase to Ewk38&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 04:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907466#M24261</guid>
      <dc:creator>dsam</dc:creator>
      <dc:date>2023-12-12T04:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: I want to change color and pattern after a certain visit in proc sgplot ?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907509#M24262</link>
      <description>&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, paste code text into text box opened on the forum with the &amp;lt;/&amp;gt; icon. Attachments require downloading and have the same concerns as spreadsheets.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 12:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907509#M24262</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-12T12:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: I want to change color and pattern after a certain visit in proc sgplot ?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907580#M24263</link>
      <description>proc format;&lt;BR /&gt;value avis&lt;BR /&gt;&lt;BR /&gt;0= 'HBase'&lt;BR /&gt;1= 'HWk20'&lt;BR /&gt;2= 'HWk38'&lt;BR /&gt;3= 'EBase'&lt;BR /&gt;4= 'EWk20'&lt;BR /&gt;5= 'EWk38'&lt;BR /&gt;6= 'Early Termination';&lt;BR /&gt;&lt;BR /&gt;value stu&lt;BR /&gt;&lt;BR /&gt;1= 'Harmony'&lt;BR /&gt;2='Encore';&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sgplot data= dum2&amp;amp;var3&amp;amp;var4 ;&lt;BR /&gt;format aan avis. sno stu.;&lt;BR /&gt;title "Median and IQR Biomarker Plot for Qualifying subjects with &amp;amp;var1 and &amp;amp;var2";&lt;BR /&gt;series x=aan y=hmedian//*markers markerattrs= (symbol=circlefilled size=9)*/ group=res /*curvelabel*/;&lt;BR /&gt;Yaxis label="&amp;amp;var2";&lt;BR /&gt;xaxis label="Analysis Visit";&lt;BR /&gt;highlow x=aan high =hp75 low=hp25//*lineattrs=(thickness=2)*/ group=res;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Dec 2023 15:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907580#M24263</guid>
      <dc:creator>dsam</dc:creator>
      <dc:date>2023-12-12T15:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: I want to change color and pattern after a certain visit in proc sgplot ?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907581#M24264</link>
      <description>&lt;P&gt;proc format;&lt;BR /&gt;value avis&lt;/P&gt;&lt;P&gt;0= 'HBase'&lt;BR /&gt;1= 'HWk20'&lt;BR /&gt;2= 'HWk38'&lt;BR /&gt;3= 'EBase'&lt;BR /&gt;4= 'EWk20'&lt;BR /&gt;5= 'EWk38'&lt;BR /&gt;6= 'Early Termination';&lt;/P&gt;&lt;P&gt;value stu&lt;/P&gt;&lt;P&gt;1= 'Harmony'&lt;BR /&gt;2='Encore';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;proc sgplot data= dum2&amp;amp;var3&amp;amp;var4 ;&lt;BR /&gt;format aan avis. sno stu.;&lt;BR /&gt;title "Median and IQR Biomarker Plot for Qualifying subjects with &amp;amp;var1 and &amp;amp;var2";&lt;BR /&gt;series x=aan y=hmedian//*markers markerattrs= (symbol=circlefilled size=9)*/ group=res /*curvelabel*/;&lt;BR /&gt;Yaxis label="&amp;amp;var2";&lt;BR /&gt;xaxis label="Analysis Visit";&lt;BR /&gt;highlow x=aan high =hp75 low=hp25//*lineattrs=(thickness=2)*/ group=res;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 15:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907581#M24264</guid>
      <dc:creator>dsam</dc:creator>
      <dc:date>2023-12-12T15:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: I want to change color and pattern after a certain visit in proc sgplot ?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907582#M24265</link>
      <description>I have added sas data and my code is posted here as well.</description>
      <pubDate>Tue, 12 Dec 2023 15:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907582#M24265</guid>
      <dc:creator>dsam</dc:creator>
      <dc:date>2023-12-12T15:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: I want to change color and pattern after a certain visit in proc sgplot ?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907634#M24266</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/448003"&gt;@dsam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to change the color of a line within the line, you will need to create separate line segments for each section of the line that will be drawn with the same color.&lt;/P&gt;
&lt;P&gt;A new data set variable would be created to identify each line segment and use this new variable as the GROUP= variable on the SERIES statement in PROC SGPLOT.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To associate the group values with the line colors and line patterns, you would define an attribute map.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To see a descriptive value in the legend, you would use PROC FORMAT to associate the new group variable with the text you want to see.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is a sample that demonstrates this approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Marcia&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value avis
0= 'HBase'
1= 'HWk20'
2= 'HWk38'
3= 'EBase'
4= 'EWk20'
5= 'EWk38'
6= 'Early Termination';

value grpfmt
1="R-R to EBase" 2="R-R Ebase to EWK38"
3="R-NR to EBase" 4="R-NR Ebase to EWK38"
5="NR-R to EBase" 6="NR-R Ebase to EWK38"
7="NR-NR to EBase" 8="NR-NR Ebase to EWK38";
run;
data sampledata;
  input aan hmedian res : $7. hp75 hp25;
	datalines;
0 0.300 NR-NR 0.390 0.300 
1 0.950 NR-NR 2.005 0.470 
2 0.965 NR-NR 1.385 0.545 
3 1.015 NR-NR 1.400 0.535 
4 0.650 NR-NR 0.940 0.360 
5 0.360 NR-NR 0.360 0.360 
0 0.300 NR-R 0.300 0.300 
1 3.100 NR-R 6.920 0.625 
2 1.630 NR-R 4.670 0.650 
3 2.430 NR-R 7.210 0.820 
4 3.885 NR-R 10.865 1.145 
5 5.230 NR-R 9.980 0.480 
0 0.300 R-NR 0.300 0.300 
1 2.040 R-NR 2.040 2.040 
2 1.650 R-NR 1.650 1.650 
3 1.830 R-NR 1.830 1.830 
4 3.260 R-NR 3.260 3.260 
5 3.070 R-NR 3.070 3.070 
0 0.500 R-R 1.030 0.300 
1 2.020 R-R 4.290 0.630 
2 3.400 R-R 9.830 0.610 
3 3.330 R-R 22.200 1.950 
4 7.410 R-R 29.300 1.510 
5 7.445 R-R 20.900 0.780 
;
run;
proc sort data=sampledata;
  by res ;
run;
data newsample;
  set sampledata;
	  by res ;
		retain grpstart;
	drop grpstart;
	if first.res then do;
	select;
 	  when (res='R-R') grpstart=1;
      when (res='R-NR') grpstart=3;
	  when (res='NR-R') grpstart=5;
	  when (res='NR-NR') grpstart=7;
		otherwise;
	end;
	end;
  colorgrp=grpstart;
  if aan=3 then output;
  if aan &amp;gt;=3 and aan &amp;lt;=5 then colorgrp=grpstart+1;
  output;
run;
data attrmap;
  id='colors';
  show='attrmap';
  length linecolor linepattern $5;
  input v linecolor $ linepattern $;
  value=put(v,grpfmt.);
  datalines;
1 green solid
2 green dash
3 green solid
4 red dash
5 red solid
6 green dash
7 red solid
8 red dash
;
run;
ods graphics / attrpriority=none;
proc sgplot data=newsample dattrmap=attrmap;
format aan avis. colorgrp grpfmt.;
title "Median and IQR Biomarker Plot for Qualifying subjects with var1 and var2";
series x=aan y=hmedian/ group=colorgrp attrid=colors name='lines';
Yaxis label="var2";
xaxis label="Analysis Visit";
keylegend 'lines' / title='';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Dec 2023 19:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/907634#M24266</guid>
      <dc:creator>MarciaS</dc:creator>
      <dc:date>2023-12-12T19:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: I want to change color and pattern after a certain visit in proc sgplot ?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/908555#M24270</link>
      <description>&lt;P&gt;Thank you so much! This makes sense and thank you for the code. I appreciate your help so much.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 08:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/I-want-to-change-color-and-pattern-after-a-certain-visit-in-proc/m-p/908555#M24270</guid>
      <dc:creator>dsam</dc:creator>
      <dc:date>2023-12-18T08:08:52Z</dc:date>
    </item>
  </channel>
</rss>

