<?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: Macro for PROC SGPLOT refline in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/609575#M17907</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm making a Bland-Altman plot where I compare a reader's values with a gold standard. LOWER_&amp;amp;THISSUFFIX and UPPER_&amp;amp;THISSUFFIX represent the lower/upper limits of agreement between the two, calculated as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[(mean difference between reader and gold for a body part) - 1.96(standard deviation of the differences for a body part)]&lt;/P&gt;&lt;P&gt;[(mean difference between reader and gold for a body part) + 1.96(standard deviation of the differences for a body part)]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since LOWER_ARM (as an example) has the same value for all records, I'd like one horizontal line rather than error bars for each of my observations.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Dec 2019 00:16:52 GMT</pubDate>
    <dc:creator>bkq32</dc:creator>
    <dc:date>2019-12-05T00:16:52Z</dc:date>
    <item>
      <title>Macro for PROC SGPLOT refline</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/608376#M17660</link>
      <description>&lt;PRE&gt;data have;&lt;BR /&gt;input id $3. mean_arm mean_leg diff_arm diff_leg upper_arm upper_leg lower_arm lower_leg reader_arm reader_leg;&lt;BR /&gt;cards;&lt;BR /&gt;ABC 878 787 2 1 8 9 -4 -3 872 788&lt;BR /&gt;DEF 600 500 7 4 10 11 -8 -7 590 501&lt;BR /&gt;GHI 300 200 12 4 11 8 -11 -10 299 202&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;Using a data set like the one above with several body measurements (body part specified in the suffix of the variable name), I made a macro for PROC SGPLOT which plots DIFF_&amp;amp;thissuffix against MEAN_&amp;amp;thissuffix for each body part:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro graph(suffixes= );
 %let nsuffix=%sysfunc(countw(&amp;amp;suffixes));

 %do i= 1 %to &amp;amp;nsuffix;
 %let thissuffix=%scan(&amp;amp;suffixes,&amp;amp;i,%str( ));

proc sgplot data=have;
 scatter x=mean_&amp;amp;thissuffix y=diff_&amp;amp;thissuffix;
 run; quit;
 %end;
%mend;

%graph (suffixes= arm leg);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How do I add a REFLINE statement that makes horizontal lines at LOWER_&amp;amp;thissuffix and UPPER_&amp;amp;this.suffix? For a particular body part, the values of LOWER_&amp;amp;thissuffix are the same for all records, as are those for UPPER_&amp;amp;thissuffix.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 22:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/608376#M17660</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2019-11-29T22:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for PROC SGPLOT refline</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/608444#M17675</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288620"&gt;@bkq32&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please provide more information about what does lower_&amp;amp;thissuffix and upper_&amp;amp;thissuffix represent?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you should explore the following options in the SCATTER statement of your PROC SGPLOT&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=have;
 scatter x=mean_&amp;amp;thissuffix y=diff_&amp;amp;thissuffix / yerrorlower=lower_&amp;amp;thissuffix yerrorupper=upper_&amp;amp;thissuffix;
 run; quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;"yerrorlower" specifies a variable that contains the lower endpoints for the Y error bars&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"yerrorupper" specifies a variable that contains the upper endpoints for the Y error bars.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;in the same way, you have also xerrorupper and yerrorupper&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 14:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/608444#M17675</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-11-30T14:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for PROC SGPLOT refline</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/608445#M17676</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288620"&gt;@bkq32&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;data have;&lt;BR /&gt;input id $3. mean_arm mean_leg diff_arm diff_leg upper_arm upper_leg lower_arm lower_leg reader_arm reader_leg;&lt;BR /&gt;cards;&lt;BR /&gt;ABC 878 787 2 1 8 9 -4 -3 872 788&lt;BR /&gt;DEF 600 500 7 4 10 11 -8 -7 590 501&lt;BR /&gt;GHI 300 200 12 4 11 8 -11 -10 299 202&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;Using a data set like the one above with several body measurements (body part specified in the suffix of the variable name), I made a macro for PROC SGPLOT which plots DIFF_&amp;amp;thissuffix against MEAN_&amp;amp;thissuffix for each body part:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro graph(suffixes= );
 %let nsuffix=%sysfunc(countw(&amp;amp;suffixes));

 %do i= 1 %to &amp;amp;nsuffix;
 %let thissuffix=%scan(&amp;amp;suffixes,&amp;amp;i,%str( ));

proc sgplot data=have;
 scatter x=mean_&amp;amp;thissuffix y=diff_&amp;amp;thissuffix;
 run; quit;
 %end;
%mend;

%graph (suffixes= arm leg);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How do I add a REFLINE statement that makes horizontal lines at LOWER_&amp;amp;thissuffix and UPPER_&amp;amp;this.suffix? For a particular body part, the values of LOWER_&amp;amp;thissuffix are the same for all records, as are those for UPPER_&amp;amp;thissuffix.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Somewhere, you have to calculate LOWER_&amp;amp;thissuffix and UPPER_&amp;amp;thissuffix before your run PROC SGPLOT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact, this is a common mistake. First, you have to figure out how to do this calculation and create a working REFLINE statement &lt;EM&gt;without&lt;/EM&gt; using macros, for one plot. You haven't done this. Once you create such a working version of SAS code without macros, then creating a working macro which includes the desired REFLINE statement inside PROC SGPLOT ought to be easy enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, task number 1, create code that does the desired SGPLOT with REFLINEs without macros, for a single instance of the plot.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 16:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/608445#M17676</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-30T16:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for PROC SGPLOT refline</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/609574#M17906</link>
      <description>&lt;P&gt;Thanks, Paige. I did that here and it created the desired plot for ARM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
 set have;

 upper_arm=meandiff_arm+1.96*stddiff_arm;
 lower_arm=meandiff_arm-1.96*stddiff_arm;

 upper_leg=meandiff_leg+1.96*stddiff_leg;
 lower_leg=meandiff_leg-1.96*stddiff_leg;
run;

proc sgplot data=have2;
 scatter x=mean_arm y=diff_arm;
 refline 0 -7.592 2.992;
 needle x=reader_arm
        y=diff_arm / baseline=0;
 yaxis values=(-8 to 8 by 2);
 title "Bland-Altman Plot (arm)";
run; quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm thinking the next step is to use CALL SYMPUT to store the values of UPPER_: and LOWER_:, and then call it in the REFLINE statement? I'm not too familiar with CALL SYMPUT yet.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 00:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/609574#M17906</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2019-12-05T00:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for PROC SGPLOT refline</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/609575#M17907</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm making a Bland-Altman plot where I compare a reader's values with a gold standard. LOWER_&amp;amp;THISSUFFIX and UPPER_&amp;amp;THISSUFFIX represent the lower/upper limits of agreement between the two, calculated as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[(mean difference between reader and gold for a body part) - 1.96(standard deviation of the differences for a body part)]&lt;/P&gt;&lt;P&gt;[(mean difference between reader and gold for a body part) + 1.96(standard deviation of the differences for a body part)]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since LOWER_ARM (as an example) has the same value for all records, I'd like one horizontal line rather than error bars for each of my observations.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 00:16:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-for-PROC-SGPLOT-refline/m-p/609575#M17907</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2019-12-05T00:16:52Z</dc:date>
    </item>
  </channel>
</rss>

