<?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 PROC SGPLOT  axis label creation and Legend Issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785418#M250651</link>
    <description>&lt;P&gt;I am trying to create a graph, using SGPLOT with both scatter and series statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Please correct me if I am using the wrong type of Graphs statement for this kind of graphs ( I just want to show %chg Vs percentage of population). I want to show data point and a line connecting them.&lt;/P&gt;
&lt;P&gt;2. Why my key legend shows 4 different groups, instead of showing two groups where circle should overlap the line?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1639149371855.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66621i0F32B8E417961C91/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1639149371855.png" alt="SASuserlot_0-1639149371855.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. I would like to insert a big arrow symbol on both sides of '0' indicating score improve or Decline!.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_1-1639149821852.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66622i27FF54AEAA170A89/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_1-1639149821852.png" alt="SASuserlot_1-1639149821852.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data trial;
input subject trt response chg;
cards;
1001 1 15 20
1002 1 16 25
1003 1 17 30
1004 1 -6 -20
1005 1 0 0
1006 1 -5 -25
1007 1 15 20
1008 1 16 25
1009 1 17 30
1010 1 18 30
1011 2 29 50
1012 2 -4 -12
1013 2 13 10
1014 2 12 8
1015 2 0 0
1016 2 28 45
1017 2 29 50
1018 2 -4 -12
1019 2 29 50
1020 2 -4 -12

;
run;

proc sort data=trial out= trial1; by trt response; run;
data trial2;
set trial1;
by trt response;
 if first.response then cnt=0;
 if .&amp;lt;chg&amp;lt;=response then cnt+1;
 if .&amp;lt;chg&amp;gt;response then cnt+1;
  if last.response then do;
   if trt=1 then yvalue=cnt/10 ;*10- indicated total poputation where trt=1 and 2;
   else if trt=2 then yvalue=cnt/10;
  end;
 run;

ods listing close;                                                                                                                      
ods html ;*file='scatterplot.html' path='.' style=styles.statistical;                                                                     
ods graphics / reset width=600px height=400px imagefmt=gif;                                                                             
                                                                                                                                        
/* The SCATTER statement generates the scatter plot with error bars. */                                                                 
/* The SERIES statement draws the line to connect the means.         */                                                                 
proc sgplot data=trial2 noautolegend;                                                                                                  
   scatter x=chg y=yvalue / group= trt;* markerattrs=(color=blue symbol=CircleFilled);                                                                
   series x=chg y=yvalue / group= trt ;*lineattrs=(color=blue pattern=2);  
	xaxis  min=-40 max=40; 
	yaxis  min=0 max= 0.5; 
keylegend / valueattrs=(size=12pt) titleattrs=(size=14pt);
run;                                                                                                                                    
                                                                                                                                        
ods html close;                                                                                                                         
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 10 Dec 2021 15:24:08 GMT</pubDate>
    <dc:creator>SASuserlot</dc:creator>
    <dc:date>2021-12-10T15:24:08Z</dc:date>
    <item>
      <title>PROC SGPLOT  axis label creation and Legend Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785418#M250651</link>
      <description>&lt;P&gt;I am trying to create a graph, using SGPLOT with both scatter and series statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Please correct me if I am using the wrong type of Graphs statement for this kind of graphs ( I just want to show %chg Vs percentage of population). I want to show data point and a line connecting them.&lt;/P&gt;
&lt;P&gt;2. Why my key legend shows 4 different groups, instead of showing two groups where circle should overlap the line?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1639149371855.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66621i0F32B8E417961C91/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1639149371855.png" alt="SASuserlot_0-1639149371855.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. I would like to insert a big arrow symbol on both sides of '0' indicating score improve or Decline!.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_1-1639149821852.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66622i27FF54AEAA170A89/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_1-1639149821852.png" alt="SASuserlot_1-1639149821852.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data trial;
input subject trt response chg;
cards;
1001 1 15 20
1002 1 16 25
1003 1 17 30
1004 1 -6 -20
1005 1 0 0
1006 1 -5 -25
1007 1 15 20
1008 1 16 25
1009 1 17 30
1010 1 18 30
1011 2 29 50
1012 2 -4 -12
1013 2 13 10
1014 2 12 8
1015 2 0 0
1016 2 28 45
1017 2 29 50
1018 2 -4 -12
1019 2 29 50
1020 2 -4 -12

;
run;

proc sort data=trial out= trial1; by trt response; run;
data trial2;
set trial1;
by trt response;
 if first.response then cnt=0;
 if .&amp;lt;chg&amp;lt;=response then cnt+1;
 if .&amp;lt;chg&amp;gt;response then cnt+1;
  if last.response then do;
   if trt=1 then yvalue=cnt/10 ;*10- indicated total poputation where trt=1 and 2;
   else if trt=2 then yvalue=cnt/10;
  end;
 run;

ods listing close;                                                                                                                      
ods html ;*file='scatterplot.html' path='.' style=styles.statistical;                                                                     
ods graphics / reset width=600px height=400px imagefmt=gif;                                                                             
                                                                                                                                        
/* The SCATTER statement generates the scatter plot with error bars. */                                                                 
/* The SERIES statement draws the line to connect the means.         */                                                                 
proc sgplot data=trial2 noautolegend;                                                                                                  
   scatter x=chg y=yvalue / group= trt;* markerattrs=(color=blue symbol=CircleFilled);                                                                
   series x=chg y=yvalue / group= trt ;*lineattrs=(color=blue pattern=2);  
	xaxis  min=-40 max=40; 
	yaxis  min=0 max= 0.5; 
keylegend / valueattrs=(size=12pt) titleattrs=(size=14pt);
run;                                                                                                                                    
                                                                                                                                        
ods html close;                                                                                                                         
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Dec 2021 15:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785418#M250651</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2021-12-10T15:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT  axis label creation and Legend Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785419#M250652</link>
      <description>&lt;P&gt;Remove the scatter statement; add the options MARKERS and MARKERATTRS=(SYMBOL=CIRCLE) to the series statement.&lt;/P&gt;
&lt;P&gt;That way you only have 1 legend element and you can't get different legends to overlay.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many other other Marker related options for the Series statement so feel free to play with them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350312"&gt;@SASuserlot&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to create a graph, using SGPLOT with both scatter and series statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Please correct me if I am using the wrong type of Graphs statement for this kind of graphs ( I just want to show %chg Vs percentage of population). I want to show data point and a line connecting them.&lt;/P&gt;
&lt;P&gt;2. Why my key legend shows 4 different groups, instead of showing two groups where circle should overlap the line?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1639149371855.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66621i0F32B8E417961C91/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1639149371855.png" alt="SASuserlot_0-1639149371855.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. I would like to insert a big arrow symbol on both sides of '0' indicating score improve or Decline!.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_1-1639149821852.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66622i27FF54AEAA170A89/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_1-1639149821852.png" alt="SASuserlot_1-1639149821852.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data trial;
input subject trt response chg;
cards;
1001 1 15 20
1002 1 16 25
1003 1 17 30
1004 1 -6 -20
1005 1 0 0
1006 1 -5 -25
1007 1 15 20
1008 1 16 25
1009 1 17 30
1010 1 18 30
1011 2 29 50
1012 2 -4 -12
1013 2 13 10
1014 2 12 8
1015 2 0 0
1016 2 28 45
1017 2 29 50
1018 2 -4 -12
1019 2 29 50
1020 2 -4 -12

;
run;

proc sort data=trial out= trial1; by trt response; run;
data trial2;
set trial1;
by trt response;
 if first.response then cnt=0;
 if .&amp;lt;chg&amp;lt;=response then cnt+1;
 if .&amp;lt;chg&amp;gt;response then cnt+1;
  if last.response then do;
   if trt=1 then yvalue=cnt/10 ;*10- indicated total poputation where trt=1 and 2;
   else if trt=2 then yvalue=cnt/10;
  end;
 run;

ods listing close;                                                                                                                      
ods html ;*file='scatterplot.html' path='.' style=styles.statistical;                                                                     
ods graphics / reset width=600px height=400px imagefmt=gif;                                                                             
                                                                                                                                        
/* The SCATTER statement generates the scatter plot with error bars. */                                                                 
/* The SERIES statement draws the line to connect the means.         */                                                                 
proc sgplot data=trial2 noautolegend;                                                                                                  
   scatter x=chg y=yvalue / group= trt;* markerattrs=(color=blue symbol=CircleFilled);                                                                
   series x=chg y=yvalue / group= trt ;*lineattrs=(color=blue pattern=2);  
	xaxis  min=-40 max=40; 
	yaxis  min=0 max= 0.5; 
keylegend / valueattrs=(size=12pt) titleattrs=(size=14pt);
run;                                                                                                                                    
                                                                                                                                        
ods html close;                                                                                                                         
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 15:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785419#M250652</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-10T15:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT  axis label creation and Legend Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785445#M250663</link>
      <description>&lt;P&gt;Legend, data points fixed. Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;. How about inserting the 'Arrow' Labels under the axis like I mentioned in the image.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 17:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785445#M250663</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2021-12-10T17:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT  axis label creation and Legend Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785525#M250705</link>
      <description>&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2016/05/30/ctspedia-clinical-graphs-subgrouped-forest-plot/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2016/05/30/ctspedia-clinical-graphs-subgrouped-forest-plot/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2012/09/30/forest-plot-with-subgroups/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2012/09/30/forest-plot-with-subgroups/&lt;/A&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:11:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785525#M250705</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-12-11T11:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT  axis label creation and Legend Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785529#M250706</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data trial;
input subject trt response chg;
cards;
1001 1 15 20
1002 1 16 25
1003 1 17 30
1004 1 -6 -20
1005 1 0 0
1006 1 -5 -25
1007 1 15 20
1008 1 16 25
1009 1 17 30
1010 1 18 30
1011 2 29 50
1012 2 -4 -12
1013 2 13 10
1014 2 12 8
1015 2 0 0
1016 2 28 45
1017 2 29 50
1018 2 -4 -12
1019 2 29 50
1020 2 -4 -12

;
run;

proc sort data=trial out= trial1; by trt response; run;
data trial2;
set trial1;
by trt response;
 if first.response then cnt=0;
 if .&amp;lt;chg&amp;lt;=response then cnt+1;
 if .&amp;lt;chg&amp;gt;response then cnt+1;
  if last.response then do;
   if trt=1 then yvalue=cnt/10 ;*10- indicated total poputation where trt=1 and 2;
   else if trt=2 then yvalue=cnt/10;
  end;
 run;

data arrow;
y=0;y1=0.05;
low1=-30;high1=-10;x1=-20;text='YYYYYYYY';output;
call missing(of _all_);
y=0;y1=0.05;
low2=10 ;high2=30;x2=20;text='XXXXXXX';output;
run;
data trial3;
 set trial2 arrow;
run;

ods graphics / reset width=600px height=400px imagefmt=gif;                                                                             
                                                                                                                                        
/* The SCATTER statement generates the scatter plot with error bars. */                                                                 
/* The SERIES statement draws the line to connect the means.         */                                                                 
proc sgplot data=trial3 ;                                                                                                  
   series x=chg y=yvalue / group= trt markers name='a';*lineattrs=(color=blue pattern=2);  
   highlow y=y low=low1 high=high1/lowcap=BARBEDARROW ; 
   highlow y=y low=low2 high=high2/highcap=BARBEDARROW ;
   text y=y1 x=x1 text=text/strip CONTRIBUTEOFFSETS=none;
   text y=y1 x=x2 text=text/strip CONTRIBUTEOFFSETS=none;
	xaxis  min=-40 max=40; 
	yaxis  min=0 max= 0.5; 
keylegend 'a' / valueattrs=(size=12pt) titleattrs=(size=14pt);
run;                                                                                                                                    
                                                                                                                                        
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_1-1639222306301.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66640i47BDCA909F6B935B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_1-1639222306301.png" alt="Ksharp_1-1639222306301.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785529#M250706</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-12-11T11:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT  axis label creation and Legend Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785564#M250719</link>
      <description>&lt;P&gt;Perfect. for my future understanding .. we have to create a separate data sets guiding the axis points and append to the original dataset, in order to place any thing under the graph for the things that we can not&amp;nbsp; be achieved in the sgplot? Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785564#M250719</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2021-12-11T16:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT  axis label creation and Legend Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785567#M250721</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785567#M250721</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2021-12-11T17:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT  axis label creation and Legend Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785617#M250753</link>
      <description>Yes. I think so.&lt;BR /&gt;Or you could refer to the blog URL I posted before.</description>
      <pubDate>Sun, 12 Dec 2021 09:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-axis-label-creation-and-Legend-Issue/m-p/785617#M250753</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-12-12T09:11:44Z</dc:date>
    </item>
  </channel>
</rss>

