<?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 Re: Add a second x-axis in PROC SGPLOT with vline: same response variable, different x in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Add-a-second-x-axis-in-PROC-SGPLOT-with-vline-same-response/m-p/713155#M20964</link>
    <description>You are a genius. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Many thanks!!!</description>
    <pubDate>Thu, 21 Jan 2021 18:12:21 GMT</pubDate>
    <dc:creator>marta25</dc:creator>
    <dc:date>2021-01-21T18:12:21Z</dc:date>
    <item>
      <title>Add a second x-axis in PROC SGPLOT with vline: same response variable, different x</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-a-second-x-axis-in-PROC-SGPLOT-with-vline-same-response/m-p/713047#M20961</link>
      <description>&lt;P&gt;I need to add a second x-axis on a plot using PROC SGPLOT in Sas. It is a time series with vline (because it is mean values with error bars). My dataset has the following columns:&lt;/P&gt;&lt;P&gt;ID (subjects)&lt;/P&gt;&lt;P&gt;treatment&lt;/P&gt;&lt;P&gt;time_elapsed (num)&lt;/P&gt;&lt;P&gt;clocktime (num)&lt;/P&gt;&lt;P&gt;Response.&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;   proc sgplot data=mydata ; 
        vline time_elapsed / response=Response stat=mean limitstat=stderr numstd=2 
            / group=condition ;
   xaxis label="Time elapsed [hours]" values=(0 to 9 by 1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This gives my elapsed time on the x-axis. I would like to have another x-axis, maybe on top of the plot, with "clock time" - that is on the same scale (hours). I can not do so:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;proc sgplot data=mydata ; 
            vline time_elapsed / response=Response stat=mean limitstat=stderr numstd=2 
                / group=condition ;
            vline clocktime / response=Response stat=mean limitstat=stderr numstd=2 
                / group=condition x2axis;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Because the category variable should be the same. And I must use "vline" to be able to represent mean values and error bars. Any other idea?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 12:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-a-second-x-axis-in-PROC-SGPLOT-with-vline-same-response/m-p/713047#M20961</guid>
      <dc:creator>marta25</dc:creator>
      <dc:date>2021-01-21T12:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add a second x-axis in PROC SGPLOT with vline: same response variable, different x</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-a-second-x-axis-in-PROC-SGPLOT-with-vline-same-response/m-p/713110#M20962</link>
      <description>&lt;P&gt;Your best option would be to use PROC MEANS or PROC SUMMARY to calculate the numbers for each overlay, merge the results into one data set, and use SERIES and SCATTER plots (with error bars) to display the result. This following code is uses this technique with some sample data. Just substitute your data and variables. Let me know if you have any questions about the details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=sashelp.heart nway;
class weight_status;
var cholesterol;
output out=weight mean=chol_wgt stderr=se_wgt;
run;

proc summary data=sashelp.heart nway;
class chol_status;
var cholesterol;
output out=chol mean=chol_chol stderr=se_chol;
run;

data merged;
set weight chol;
wgt_upper = chol_wgt + se_wgt;
wgt_lower = chol_wgt - se_wgt;
chol_upper = chol_chol + se_chol;
chol_lower = chol_chol - se_chol;
run;

proc sgplot data=merged cycleattrs;
series x=weight_status y=chol_wgt / name="weight" lineattrs=graphdata1;
scatter x=weight_status y=chol_wgt / markerattrs=graphdata1(size=0)
        yerrorupper=wgt_upper yerrorlower=wgt_lower;
series x=chol_status y=chol_chol / x2axis name="chol" lineattrs=graphdata2;
scatter x=chol_status y=chol_chol/ markerattrs=graphdata2(size=0) x2axis
        yerrorupper=chol_upper yerrorlower=chol_lower;
keylegend "weight" "chol";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jan 2021 16:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-a-second-x-axis-in-PROC-SGPLOT-with-vline-same-response/m-p/713110#M20962</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2021-01-21T16:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Add a second x-axis in PROC SGPLOT with vline: same response variable, different x</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-a-second-x-axis-in-PROC-SGPLOT-with-vline-same-response/m-p/713155#M20964</link>
      <description>You are a genius. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Many thanks!!!</description>
      <pubDate>Thu, 21 Jan 2021 18:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-a-second-x-axis-in-PROC-SGPLOT-with-vline-same-response/m-p/713155#M20964</guid>
      <dc:creator>marta25</dc:creator>
      <dc:date>2021-01-21T18:12:21Z</dc:date>
    </item>
  </channel>
</rss>

