<?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 - Add a 2nd variable to a 2nd Y axis in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/817374#M34506</link>
    <description>&lt;P&gt;How do I add a new variable and a new Y axis to a line graph using PROC SGPLOT?&lt;/P&gt;
&lt;P&gt;The syntax at the bottom of this post produces this line graph:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Figure 1.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72108i35192977FE66BF69/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure 1.jpg" alt="Figure 1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am outputting percentages from a PROC FREQ and then graphing the percentage over time, by a grouping variable&amp;nbsp;(i.e.,&amp;nbsp;group = cann_use_status) using a format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VALUE&amp;nbsp;&lt;BR /&gt;cann_use_statusfmt&lt;BR /&gt;1 = "Never"&lt;BR /&gt;2 = "Past Use"&lt;BR /&gt;3 = "Current Use, Light (&amp;lt; 5d/past mo)"&lt;BR /&gt;4 = "Current, Heavy (≥ 5d/past mo)";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want a graph that looks like this (see &lt;FONT color="#FF00FF"&gt;pink dotted line&lt;/FONT&gt;)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-06-09 at 4.20.33 PM.png" style="width: 737px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72111iC7C60E5692FA3CF9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-06-09 at 4.20.33 PM.png" alt="Screen Shot 2022-06-09 at 4.20.33 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example, the pink line is the grouping variable, but with a different format (see below). But...I would like to learn how to add&amp;nbsp;any variable to a second axis (assuming the units are the same).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VALUE&amp;nbsp;&lt;BR /&gt;cann_use_status3fmt&lt;BR /&gt;1 = "Never"&lt;BR /&gt;2 = "Past Use"&lt;BR /&gt;3,4 = "Current Use";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to graph the column percent (i.e., the percentage of respondents in that year that identify as current users).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 1st Y axis is the percentage reporting a prior MI (i.e., heart attack)&amp;nbsp;&lt;STRONG&gt;by the grouping variable &lt;/STRONG&gt;(i.e.,&amp;nbsp;cann_use_status). I'd like to add cann_use_status to the other Y axis&amp;nbsp;(i.e., percentage of current users, independent of MI status).&lt;/P&gt;
&lt;P&gt;Sorry for the long, complicated post. Thanks for any assistance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ DATA=nhanes.go;
	where cann_use_status ne .;	
 	TABLE ever_told_mi*year*cann_use_status / outpct out=freqout;
 	format cann_use_status cann_use_statusfmt.;
run;


proc sgplot data=freqout ;
   where ever_told_mi=1;&lt;BR /&gt;
   series x=year y=pct_row
&lt;BR /&gt;   / lineattrs=(thickness=2px) markers DATALABEL=pct_row group=cann_use_status;
   xaxis 
   label = "Time in 2-year intervals"
   values=(2009-2010 to 2017-2018);
  
   yaxis 
   label = "Percentage Reporting Prior MI"
   values=(0 to 100 by 10)
   VALUESFORMAT=f8.1;
 	
   format 
   ever_told_mi yes_nofmt.
   cann_use_status cann_use_statusfmt.
   pct_row 8.1;
   
   title "Figure 1b. Percentage of Middle-Aged Adults Reporting Prior MI in NHANES Biennial Examinations, by Cannabis Use Status and year (2009-2020)";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Create table freqout(ever_told_mi float, year varchar(9), cann_use_status float, count float, percent float, pct_tabl float, pct_row float, pct_col float);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2009-2010', 1, 145, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2009-2010', 2, 55, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2009-2010', 3, 14, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2009-2010', 4, 38, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2011-2012', 1, 134, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2011-2012', 2, 66, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2011-2012', 3, 15, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2011-2012', 4, 41, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2013-2014', 1, 156, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2013-2014', 2, 86, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2013-2014', 3, 22, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2013-2014', 4, 31, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2015-2016', 1, 126, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2015-2016', 2, 61, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2015-2016', 3, 16, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2015-2016', 4, 29, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2017-2018', 1, 114, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2017-2018', 2, 76, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2017-2018', 3, 10, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2017-2018', 4, 31, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2009-2010', 1, 23, 0.1492, 9.4262, 38.3333, 27.3810);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2009-2010', 2, 28, 0.1817, 11.4754, 46.6667, 23.1405);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2009-2010', 3, 3, 0.0195, 1.2295, 5.0000, 25.0000);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2009-2010', 4, 6, 0.0389, 2.4590, 10.0000, 22.2222);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2011-2012', 1, 10, 0.0649, 4.0984, 28.5714, 11.9048);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2011-2012', 2, 21, 0.1362, 8.6066, 60.0000, 17.3554);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2011-2012', 3, 1, 0.0065, 0.4098, 2.8571, 8.3333);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2011-2012', 4, 3, 0.0195, 1.2295, 8.5714, 11.1111);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2013-2014', 1, 15, 0.0973, 6.1475, 30.0000, 17.8571);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2013-2014', 2, 26, 0.1687, 10.6557, 52.0000, 21.4876);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2013-2014', 3, 4, 0.0260, 1.6393, 8.0000, 33.3333);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2013-2014', 4, 5, 0.0324, 2.0492, 10.0000, 18.5185);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2015-2016', 1, 19, 0.1233, 7.7869, 41.3043, 22.6190);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2015-2016', 2, 23, 0.1492, 9.4262, 50.0000, 19.0083);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2015-2016', 3, 2, 0.0130, 0.8197, 4.3478, 16.6667);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2015-2016', 4, 2, 0.0130, 0.8197, 4.3478, 7.4074);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2017-2018', 1, 17, 0.1103, 6.9672, 32.0755, 20.2381);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2017-2018', 2, 23, 0.1492, 9.4262, 43.3962, 19.0083);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2017-2018', 3, 2, 0.0130, 0.8197, 3.7736, 16.6667);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2017-2018', 4, 11, 0.0714, 4.5082, 20.7547, 40.7407);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2009-2010', 1, 1626, 10.5489, 10.7185, 49.1982, 21.7933);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2009-2010', 2, 1323, 8.5831, 8.7212, 40.0303, 22.5383);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2009-2010', 3, 97, 0.6293, 0.6394, 2.9349, 21.3656);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2009-2010', 4, 259, 1.6803, 1.7073, 7.8366, 18.7004);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2011-2012', 1, 1415, 9.1800, 9.3276, 48.7427, 18.9653);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2011-2012', 2, 1164, 7.5516, 7.6730, 40.0965, 19.8296);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2011-2012', 3, 80, 0.5190, 0.5274, 2.7558, 17.6211);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2011-2012', 4, 244, 1.5830, 1.6084, 8.4051, 17.6173);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2013-2014', 1, 1528, 9.9131, 10.0725, 47.7948, 20.4798);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2013-2014', 2, 1300, 8.4339, 8.5695, 40.6631, 22.1465);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2013-2014', 3, 90, 0.5839, 0.5933, 2.8151, 19.8238);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2013-2014', 4, 279, 1.8100, 1.8392, 8.7269, 20.1444);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2015-2016', 1, 1562, 10.1336, 10.2966, 52.0667, 20.9355);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2015-2016', 2, 1077, 6.9872, 7.0995, 35.9000, 18.3475);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2015-2016', 3, 99, 0.6423, 0.6526, 3.3000, 21.8062);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2015-2016', 4, 262, 1.6998, 1.7271, 8.7333, 18.9170);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2017-2018', 1, 1330, 8.6285, 8.7673, 48.1013, 17.8260);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2017-2018', 2, 1006, 6.5265, 6.6315, 36.3834, 17.1380);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2017-2018', 3, 88, 0.5709, 0.5801, 3.1826, 19.3833);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2017-2018', 4, 341, 2.2123, 2.2479, 12.3327, 24.6209);&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jun 2022 23:35:09 GMT</pubDate>
    <dc:creator>_maldini_</dc:creator>
    <dc:date>2022-06-09T23:35:09Z</dc:date>
    <item>
      <title>PROC SGPLOT - Add a 2nd variable to a 2nd Y axis</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/817374#M34506</link>
      <description>&lt;P&gt;How do I add a new variable and a new Y axis to a line graph using PROC SGPLOT?&lt;/P&gt;
&lt;P&gt;The syntax at the bottom of this post produces this line graph:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Figure 1.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72108i35192977FE66BF69/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure 1.jpg" alt="Figure 1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am outputting percentages from a PROC FREQ and then graphing the percentage over time, by a grouping variable&amp;nbsp;(i.e.,&amp;nbsp;group = cann_use_status) using a format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VALUE&amp;nbsp;&lt;BR /&gt;cann_use_statusfmt&lt;BR /&gt;1 = "Never"&lt;BR /&gt;2 = "Past Use"&lt;BR /&gt;3 = "Current Use, Light (&amp;lt; 5d/past mo)"&lt;BR /&gt;4 = "Current, Heavy (≥ 5d/past mo)";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want a graph that looks like this (see &lt;FONT color="#FF00FF"&gt;pink dotted line&lt;/FONT&gt;)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-06-09 at 4.20.33 PM.png" style="width: 737px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72111iC7C60E5692FA3CF9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-06-09 at 4.20.33 PM.png" alt="Screen Shot 2022-06-09 at 4.20.33 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example, the pink line is the grouping variable, but with a different format (see below). But...I would like to learn how to add&amp;nbsp;any variable to a second axis (assuming the units are the same).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VALUE&amp;nbsp;&lt;BR /&gt;cann_use_status3fmt&lt;BR /&gt;1 = "Never"&lt;BR /&gt;2 = "Past Use"&lt;BR /&gt;3,4 = "Current Use";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to graph the column percent (i.e., the percentage of respondents in that year that identify as current users).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 1st Y axis is the percentage reporting a prior MI (i.e., heart attack)&amp;nbsp;&lt;STRONG&gt;by the grouping variable &lt;/STRONG&gt;(i.e.,&amp;nbsp;cann_use_status). I'd like to add cann_use_status to the other Y axis&amp;nbsp;(i.e., percentage of current users, independent of MI status).&lt;/P&gt;
&lt;P&gt;Sorry for the long, complicated post. Thanks for any assistance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ DATA=nhanes.go;
	where cann_use_status ne .;	
 	TABLE ever_told_mi*year*cann_use_status / outpct out=freqout;
 	format cann_use_status cann_use_statusfmt.;
run;


proc sgplot data=freqout ;
   where ever_told_mi=1;&lt;BR /&gt;
   series x=year y=pct_row
&lt;BR /&gt;   / lineattrs=(thickness=2px) markers DATALABEL=pct_row group=cann_use_status;
   xaxis 
   label = "Time in 2-year intervals"
   values=(2009-2010 to 2017-2018);
  
   yaxis 
   label = "Percentage Reporting Prior MI"
   values=(0 to 100 by 10)
   VALUESFORMAT=f8.1;
 	
   format 
   ever_told_mi yes_nofmt.
   cann_use_status cann_use_statusfmt.
   pct_row 8.1;
   
   title "Figure 1b. Percentage of Middle-Aged Adults Reporting Prior MI in NHANES Biennial Examinations, by Cannabis Use Status and year (2009-2020)";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Create table freqout(ever_told_mi float, year varchar(9), cann_use_status float, count float, percent float, pct_tabl float, pct_row float, pct_col float);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2009-2010', 1, 145, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2009-2010', 2, 55, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2009-2010', 3, 14, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2009-2010', 4, 38, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2011-2012', 1, 134, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2011-2012', 2, 66, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2011-2012', 3, 15, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2011-2012', 4, 41, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2013-2014', 1, 156, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2013-2014', 2, 86, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2013-2014', 3, 22, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2013-2014', 4, 31, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2015-2016', 1, 126, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2015-2016', 2, 61, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2015-2016', 3, 16, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2015-2016', 4, 29, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2017-2018', 1, 114, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2017-2018', 2, 76, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2017-2018', 3, 10, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(., '2017-2018', 4, 31, ., ., ., .);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2009-2010', 1, 23, 0.1492, 9.4262, 38.3333, 27.3810);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2009-2010', 2, 28, 0.1817, 11.4754, 46.6667, 23.1405);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2009-2010', 3, 3, 0.0195, 1.2295, 5.0000, 25.0000);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2009-2010', 4, 6, 0.0389, 2.4590, 10.0000, 22.2222);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2011-2012', 1, 10, 0.0649, 4.0984, 28.5714, 11.9048);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2011-2012', 2, 21, 0.1362, 8.6066, 60.0000, 17.3554);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2011-2012', 3, 1, 0.0065, 0.4098, 2.8571, 8.3333);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2011-2012', 4, 3, 0.0195, 1.2295, 8.5714, 11.1111);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2013-2014', 1, 15, 0.0973, 6.1475, 30.0000, 17.8571);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2013-2014', 2, 26, 0.1687, 10.6557, 52.0000, 21.4876);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2013-2014', 3, 4, 0.0260, 1.6393, 8.0000, 33.3333);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2013-2014', 4, 5, 0.0324, 2.0492, 10.0000, 18.5185);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2015-2016', 1, 19, 0.1233, 7.7869, 41.3043, 22.6190);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2015-2016', 2, 23, 0.1492, 9.4262, 50.0000, 19.0083);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2015-2016', 3, 2, 0.0130, 0.8197, 4.3478, 16.6667);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2015-2016', 4, 2, 0.0130, 0.8197, 4.3478, 7.4074);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2017-2018', 1, 17, 0.1103, 6.9672, 32.0755, 20.2381);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2017-2018', 2, 23, 0.1492, 9.4262, 43.3962, 19.0083);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2017-2018', 3, 2, 0.0130, 0.8197, 3.7736, 16.6667);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(1, '2017-2018', 4, 11, 0.0714, 4.5082, 20.7547, 40.7407);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2009-2010', 1, 1626, 10.5489, 10.7185, 49.1982, 21.7933);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2009-2010', 2, 1323, 8.5831, 8.7212, 40.0303, 22.5383);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2009-2010', 3, 97, 0.6293, 0.6394, 2.9349, 21.3656);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2009-2010', 4, 259, 1.6803, 1.7073, 7.8366, 18.7004);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2011-2012', 1, 1415, 9.1800, 9.3276, 48.7427, 18.9653);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2011-2012', 2, 1164, 7.5516, 7.6730, 40.0965, 19.8296);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2011-2012', 3, 80, 0.5190, 0.5274, 2.7558, 17.6211);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2011-2012', 4, 244, 1.5830, 1.6084, 8.4051, 17.6173);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2013-2014', 1, 1528, 9.9131, 10.0725, 47.7948, 20.4798);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2013-2014', 2, 1300, 8.4339, 8.5695, 40.6631, 22.1465);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2013-2014', 3, 90, 0.5839, 0.5933, 2.8151, 19.8238);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2013-2014', 4, 279, 1.8100, 1.8392, 8.7269, 20.1444);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2015-2016', 1, 1562, 10.1336, 10.2966, 52.0667, 20.9355);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2015-2016', 2, 1077, 6.9872, 7.0995, 35.9000, 18.3475);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2015-2016', 3, 99, 0.6423, 0.6526, 3.3000, 21.8062);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2015-2016', 4, 262, 1.6998, 1.7271, 8.7333, 18.9170);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2017-2018', 1, 1330, 8.6285, 8.7673, 48.1013, 17.8260);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2017-2018', 2, 1006, 6.5265, 6.6315, 36.3834, 17.1380);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2017-2018', 3, 88, 0.5709, 0.5801, 3.1826, 19.3833);&lt;BR /&gt;Insert into freqout(ever_told_mi, year, cann_use_status, count, percent, pct_tabl, pct_row, pct_col) Values(2, '2017-2018', 4, 341, 2.2123, 2.2479, 12.3327, 24.6209);&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 23:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/817374#M34506</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2022-06-09T23:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT - Add a 2nd variable to a 2nd Y axis</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/817382#M34507</link>
      <description>&lt;P&gt;This will get you close. Not sure how Current is calculated, doesn't appear in data so I just averaged the current values and added it as a separate series.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You specify Y2AXIS as an option on the series/scatter statement to have a secondary axis.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can control the legend with KEYLEGEND statement. Left that as an exercise to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=freqout noprint nway;
where cann_use_status in (3, 4) and ever_told_mi=1;
class year ever_told_mi;
weight count;
var pct_row;
output out=totals mean = AVG_VALUE;
run;

data freqout2;
set freqout totals;
run;

proc format;
VALUE 
cann_use_status3fmt
1 = "Never"
2 = "Past Use"
3,4 = "Current Use";

VALUE 
cann_use_statusfmt
1 = "Never"
2 = "Past Use"
3 = "Current Use, Light (&amp;lt; 5d/past mo)"
4 = "Current, Heavy (≥ 5d/past mo)";

run;

proc sgplot data=freqout2 ;
   where ever_told_mi=1;
   series x=year y=pct_row
   / lineattrs=(thickness=2px) markers DATALABEL=pct_row group=cann_use_status;
   xaxis 
   label = "Time in 2-year intervals";
   
   series x=year y=AVG_VALUE
   / lineattrs=(thickness=2px) markers DATALABEL=AVG_VALUE;
   y2axis 
   label = "Time in 2-year intervals";
   *values=(2009-2010 to 2017-2018);
  
   yaxis 
   label = "Percentage Reporting Prior MI"
   values=(0 to 100 by 10)
   VALUESFORMAT=f8.1;
   
      y2axis 
   label = "Percentage Reporting Current Use"
   values=(0 to 100 by 10)
   VALUESFORMAT=f8.1;
 	
   format 
   ever_told_mi yes_nofmt.
   cann_use_status cann_use_statusfmt.
   pct_row 8.1;
   
   title "Figure 1b. Percentage of Middle-Aged Adults Reporting Prior MI in NHANES Biennial Examinations, by Cannabis Use Status and year (2009-2020)";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jun 2022 01:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/817382#M34507</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-10T01:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT - Add a 2nd variable to a 2nd Y axis</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/817534#M34538</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;Thanks. This helps a lot.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A couple of clarifying questions (See image below):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-06-10 at 10.40.24 AM.png" style="width: 647px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72145i02C2EAB976A4FD23/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-06-10 at 10.40.24 AM.png" alt="Screen Shot 2022-06-10 at 10.40.24 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp;The other Y axis is not represented on the graph. Is there a way to add it?&lt;/P&gt;
&lt;P&gt;2. Do you know what the dotted grey line in the legend represents (i.e., how do I get rid of it. Full PROC SGPLOT syntax at the end of the post)?&lt;/P&gt;
&lt;P&gt;3. The pink line is a good proof of concept, but it is not graphing the correct percentage (my fault, not yours). I want to graph the column percent using a different format (or in the future, a totally different nominal variable). Based on my limited knowledge, I would run a separate PROC FREQ and output a different column percent. This is my attempt to mimic your PROC MEANS approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ DATA=nhanes.go;
	where cann_use_status ne .;
 	TABLE ever_told_mi*(cann_use_status)*year / outpct out=freqout_1;
 	format cann_use_status cann_use_statusfmt.;
run;

PROC FREQ DATA=nhanes.go;
	where cann_use_status ne .;
 	TABLE ever_told_mi*(cann_use_status)*year / outpct out=freqout_3;
 	format cann_use_status cann_use_status3fmt.;
run;

data freqout_4;
set freqout_1 freqout_3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The 2nd PROC FREQ uses the different format. The problem is that the column percent&amp;nbsp;(i.e.,&amp;nbsp;PCT_COL) has the same name in the outputted data sets (i.e., freqout_1 and&amp;nbsp;freqout_3), so I can't identify it as a separate variable in the PROC SGPLOT (see image below). There is only 1 PCT_COL.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-06-10 at 12.05.45 PM.png" style="width: 785px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72146i0DACACADCF4AD4B5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-06-10 at 12.05.45 PM.png" alt="Screen Shot 2022-06-10 at 12.05.45 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I don't see a way to specify the statistics to output in a PROC FREQ (e.g., row_pct, col_pct, etc.) like you would in a PROC MEANS (e.g., mean, max, etc.). Does it simply output everything? Also,&amp;nbsp;is there a way to specify the name of an outputted variable&amp;nbsp;in PROC FREQ&amp;nbsp;(e.g., PCT_COL = col_pct_2)?&amp;nbsp;This would be similar to "output out=totals mean = AVG_VALUE;" in the PROC MEANS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=freqout2 ;
   where ever_told_mi=1;
   
   series x=year y=pct_row
   / lineattrs=(thickness=2px) markers DATALABEL=pct_row group=cann_use_status;
   
   xaxis 
   label = "Time in 2-year intervals";
   
   yaxis 
   label = "Percentage Reporting Prior MI"
   values=(0 to 60 by 10)
   VALUESFORMAT=f8.1;
   
   series x=year y=AVG_VALUE
   / lineattrs=(thickness=4px) markers DATALABEL=AVG_VALUE 
   
   legendlabel="Percentage Reporting Current Use";
   keylegend / position=bottom ;;
   
   x2axis 
   label = "Time in 2-year intervals";
   *values=(2009-2010 to 2017-2018);
 
   y2axis 
   label = "Percentage Reporting Current Use"
   values=(0 to 60 by 10)
   VALUESFORMAT=f8.1;
	
   format 
   ever_told_mi yes_nofmt.
   cann_use_status cann_use_statusfmt.
   pct_row 8.1
   avg_value 8.1;
   
   title "Figure 1b. Percentage of Middle-Aged Adults Reporting Prior MI in NHANES Biennial Examinations, by Cannabis Use Status and year (2009-2020)";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 19:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/817534#M34538</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2022-06-10T19:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT - Add a 2nd variable to a 2nd Y axis</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/817540#M34541</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/36911"&gt;@_maldini_&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A couple of clarifying questions (See image below):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp;The other Y axis is not represented on the graph. Is there a way to add it?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You never actually put the Y2AXIS option in your code, recheck it against my code and run it. Should have the second axis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;2. Do you know what the dotted grey line in the legend represents (i.e., how do I get rid of it. Full PROC SGPLOT syntax at the end of the post)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I suspect that's the output from your second PROC FREQ.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the data structure on the data set I created and compare it to yours. It is not the same. You need to have a new variable in the data set, you cannot reuse the same variable on a different axis or at least it doesn't make sense in context of your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The 2nd PROC FREQ uses the different format. The problem is that the column percent&amp;nbsp;(i.e.,&amp;nbsp;PCT_COL) has the same name in the outputted data sets (i.e., freqout_1 and&amp;nbsp;freqout_3), so I can't identify it as a separate variable in the PROC SGPLOT (see image below). There is only 1 PCT_COL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't see a way to specify the statistics to output in a PROC FREQ (e.g., row_pct, col_pct, etc.) like you would in a PROC MEANS (e.g., mean, max, etc.). Does it simply output everything? Also,&amp;nbsp;is there a way to specify the name of an outputted variable&amp;nbsp;in PROC FREQ&amp;nbsp;(e.g., PCT_COL = col_pct_2)?&amp;nbsp;This would be similar to "output out=totals mean = AVG_VALUE;" in the PROC MEANS.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can rename any variable in a data set using the data set options.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In PROC FREQ the statistics are output by default and you suppress them with options, such as &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_freq_syntax08.htm#procstat.freq.freqnorow" target="_self"&gt;norow&lt;/A&gt;, nopercent etc. See the PROC FREQ documentations for details.&amp;nbsp; You cannot specify the names but you can easily rename them using a data set option either on the OUT= data set or the SET statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data freqout_4;
set freqout_1 freqout_3 &lt;FONT color="#800080"&gt;&lt;STRONG&gt;(rename=pct_col=pct_col_y2)&lt;/STRONG&gt;&lt;/FONT&gt;;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jun 2022 19:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/817540#M34541</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-10T19:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT - Add a 2nd variable to a 2nd Y axis</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/818155#M34599</link>
      <description>&lt;P&gt;&amp;lt;You never actually put the Y2AXIS option in your code, recheck it against my code and run it. Should have the second axis.&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run your code it doesn't add the axis. I copied and pasted it verbatim. This is the graph (below).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-06-14 at 9.56.44 AM.png" style="width: 663px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72280i21C214CE0F876061/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-06-14 at 9.56.44 AM.png" alt="Screen Shot 2022-06-14 at 9.56.44 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 16:57:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/818155#M34599</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2022-06-14T16:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT - Add a 2nd variable to a 2nd Y axis</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/818179#M34607</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Reeza_0-1655230615685.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72283iEDDB344212ADC2E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Reeza_0-1655230615685.png" alt="Reeza_0-1655230615685.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;From this code&lt;/P&gt;
&lt;P&gt;LABEL is not valid within the SERIES statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=freqout2 ;
   where ever_told_mi=1;
   series x=year y=pct_row
   / markers lineattrs=(thickness=2px) group=cann_use_status DATALABEL=pct_row; ;
   
   series x=year y=AVG_VALUE
   / markers lineattrs=(thickness=2px)  y2axis DATALABEL=AVG_VALUE;

   *values=(2009-2010 to 2017-2018);
  
    yaxis 
   label = "Percentage Reporting Prior MI"
   values=(0 to 100 by 10)
   VALUESFORMAT=f8.1;
   
     y2axis 
   label = "Percentage Reporting Current Use"
   values=(0 to 100 by 10)
   VALUESFORMAT=f8.1;
 	
   format 
   ever_told_mi yes_nofmt.
   cann_use_status cann_use_statusfmt.
   pct_row 8.1;

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jun 2022 18:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SGPLOT-Add-a-2nd-variable-to-a-2nd-Y-axis/m-p/818179#M34607</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-14T18:17:38Z</dc:date>
    </item>
  </channel>
</rss>

