<?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: PROC SURVEYREG - Box Plot in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854182#M37600</link>
    <description>&lt;P&gt;The LSMEANS statement uses the same order as the CLASS statement, so look at &lt;A href="https://go.documentation.sas.com/doc/en/stathpug/15.2/stathpug_introcom_stat_sect003.htm" target="_self"&gt;the documentation of the CLASS statement.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default, the levels of a classification variable are listed alphabetically by their formatted value (order=formatted). The most useful way to change the order is to sort or otherwise arrange the input data set in the order you want, and then use the ORDER=DATA option on the CLASS statement to specify that the order of levels is found in the data set. For your example, sort by&amp;nbsp;STRATUM and then by the YEAR variable. If that doesn't fix your problem, there are other tricks/techniques we can use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding how to use the doc, my approach to learning a new procedure is always to start with the "Overview" and "Getting Started" sections of the doc, then browse the syntax section. I leave the "Details" section for when I need to know the math/statistics behind the computation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, know that there is a section of the SAS/STAT doc devoted to &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_031/statug/statug_introcom_toc.htm" target="_self"&gt;"Shared Concepts."&lt;/A&gt;&amp;nbsp;Most procedures link to that section if they support one of the shared statements (like LSMEANS).&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jan 2023 18:57:17 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2023-01-17T18:57:17Z</dc:date>
    <item>
      <title>PROC SURVEYREG - Box Plot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854009#M37586</link>
      <description>&lt;P&gt;Is there a way to produce a box plot using&amp;nbsp;PROC SURVEYREG?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using an LSMEANS statement in&amp;nbsp;PROC SURVEYREG to calculate adjusted means for the various levels of the categorical variable in the CLASS statement (reg_use = never, non-regular use, regular use). I'd like to see these adjusted means in a box plot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SURVEYMEANS produces a box plot, but the means are not adjusted for the other variables (Adjusting for age_yrs and sex below).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyreg data=&amp;amp;dataset;
  	STRATUM sdmvstra;
 	CLUSTER sdmvpsu;
 	WEIGHT &amp;amp;weight;
 
	class reg_use (ref="Never") sex;
           
	model htn = reg_use age_yrs sex / solution clparm;
	lsmeans  reg_use / pdiff=all adjust=tukey;

   	format 
	htn					htn_fmt.
	reg_use				reg_usefmt.
	sex					sexfmt.	
	;
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 18:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854009#M37586</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2023-01-16T18:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYREG - Box Plot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854143#M37594</link>
      <description>&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_introcom_sect041.htm#statug.introcom.lsmplots" target="_self"&gt;The doc for the LSMEANS statement&lt;/A&gt; indicates that it can produce several kinds of plots. I think the most appropriate plot is the MEANPLOT, which shows the estimated mean and 95% CI for each category on the LSMEANS statement:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt; lsmeans reg_use / pdiff=all adjust=tukey plots=(meanplot);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 16:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854143#M37594</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-01-17T16:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYREG - Box Plot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854175#M37599</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 additional questions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Is there a way to control the order of the levels/groups of the variable used in the LSMEANS statement? I set the reference category in the CLASS statement, but that level/group is last in the plot. I'd like it to be first.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-01-17 at 10.26.31 AM.png" style="width: 717px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79460i64A37D3300B118AE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-01-17 at 10.26.31 AM.png" alt="Screenshot 2023-01-17 at 10.26.31 AM.png" /&gt;&lt;/span&gt;&lt;/LI&gt;
&lt;LI&gt;Do you know of a resource that I could use to better understand&lt;STRONG&gt; how to use the SAS documentation&lt;/STRONG&gt;? That might sound silly, but I struggle to make sense of the documentation sometimes.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 17 Jan 2023 18:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854175#M37599</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2023-01-17T18:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYREG - Box Plot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854182#M37600</link>
      <description>&lt;P&gt;The LSMEANS statement uses the same order as the CLASS statement, so look at &lt;A href="https://go.documentation.sas.com/doc/en/stathpug/15.2/stathpug_introcom_stat_sect003.htm" target="_self"&gt;the documentation of the CLASS statement.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default, the levels of a classification variable are listed alphabetically by their formatted value (order=formatted). The most useful way to change the order is to sort or otherwise arrange the input data set in the order you want, and then use the ORDER=DATA option on the CLASS statement to specify that the order of levels is found in the data set. For your example, sort by&amp;nbsp;STRATUM and then by the YEAR variable. If that doesn't fix your problem, there are other tricks/techniques we can use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding how to use the doc, my approach to learning a new procedure is always to start with the "Overview" and "Getting Started" sections of the doc, then browse the syntax section. I leave the "Details" section for when I need to know the math/statistics behind the computation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, know that there is a section of the SAS/STAT doc devoted to &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_031/statug/statug_introcom_toc.htm" target="_self"&gt;"Shared Concepts."&lt;/A&gt;&amp;nbsp;Most procedures link to that section if they support one of the shared statements (like LSMEANS).&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 18:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854182#M37600</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-01-17T18:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYREG - Box Plot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854183#M37601</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;P class="1673982256846"&gt;&amp;nbsp;&lt;/P&gt;
&lt;SPAN&gt;Is there a way to control the order of the levels/groups of the variable used in the LSMEANS statement? I set the reference category in the CLASS statement, but that level/group is last in the plot. I'd like it to be first.&lt;/SPAN&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-01-17 at 10.26.31 AM.png" style="width: 717px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79460i64A37D3300B118AE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-01-17 at 10.26.31 AM.png" alt="Screenshot 2023-01-17 at 10.26.31 AM.png" /&gt;&lt;/span&gt;.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Assuming that YEAR is a numeric variable with a format (is it?) then ORDER=INTERNAL in the PROC SURVEYREG statement produces the proper sorting.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 19:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854183#M37601</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-17T19:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYREG - Box Plot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854214#M37616</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;OL&gt;
&lt;LI&gt;Is there a way to control the order of the levels/groups of the variable used in the LSMEANS statement? I set the reference category in the CLASS statement, but that level/group is last in the plot. I'd like it to be first.&lt;/LI&gt;
&lt;/OL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/36911"&gt;@_maldini_&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the data from &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_surveyreg_examples08.htm" target="_blank" rel="noopener"&gt;Example 122.8 Comparing Domain Statistics&lt;/A&gt;&amp;nbsp;with a formatted numeric class variable added, the only simple way I found to change the tick mark position &lt;EM&gt;of the reference category&lt;/EM&gt; was to use the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_introcom_sect041.htm#statug_introcom007949" target="_blank" rel="noopener"&gt;ASCENDING&lt;/A&gt; or &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_introcom_sect041.htm#statug_introcom007958" target="_blank" rel="noopener"&gt;DESCENDING&lt;/A&gt; option of the MEANPLOT request. But then the order of tick marks depends on the LS mean values, which you don't want (e.g., "ASCENDING" would swap '2011-2012' and '2013-2014' in your example).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two solutions&amp;nbsp;&lt;EM&gt;did&lt;/EM&gt; work for my test data, but were more complicated:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Creating an output dataset containing the mean plot data&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output MeanPlot=mpdat;&lt;/CODE&gt;&lt;/PRE&gt;
(this statement goes before or into the PROC SURVEYREG step) and then using PROC SGPLOT &lt;FONT face="courier new,courier"&gt;data=mpdat&lt;/FONT&gt; ... (with a &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p1lcbd3lhs3t3bn1jk6d8sjt2yqx.htm" target="_blank" rel="noopener"&gt;SCATTER statement&lt;/A&gt;) to create the plot. PROC SGPLOT has an XAXIS statement where you can specify the order of tick marks with the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p07m2vpyq75fgan14m6g5pphnwlr.htm#n09f4ln7jq8gkan1w2nhlkzjcrqz" target="_blank" rel="noopener"&gt;VALUES= option&lt;/A&gt;. However, more options would need to be added in order to reproduce the original mean plot from PROC SURVEYREG.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_templt_sect011.htm" target="_blank" rel="noopener"&gt;Modifying the ODS graphics template&lt;/A&gt; used by PROC SURVEYREG: I copied the PROC TEMPLATE code of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Stat.Graphics.MeanPlot&lt;/FONT&gt; (path in the Templates window: Sashelp.Tmplstat\Stat\SurveyReg\Graphics\MeanPlot) from the template browser into the Enhanced Editor, inserted&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;discreteopts=(tickvaluelist=(&lt;EM&gt;list of quoted tick values&lt;/EM&gt;))&lt;/CODE&gt;&lt;/PRE&gt;
into the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/p0ra82ol659t4ln1ifal7w0nbydm.htm#p1hngru43pp39rn1vkxgu4u4ncqza" target="_blank" rel="noopener"&gt;XAXISOPTS= option&lt;/A&gt; of the LAYOUT OVERLAY statement, submitted this modified PROC TEMPLATE code and then the&amp;nbsp;PROC SURVEYREG step.&lt;BR /&gt;However, modifying ODS templates can be risky (see&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Is-there-a-way-to-change-the-x-axis-label-for-the/m-p/801169/highlight/true#M315284" target="_blank" rel="noopener"&gt;Re: PROC PSMATCH: Is there a way to change the x-axis label ...&lt;/A&gt;&amp;nbsp;also for more details).&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 17 Jan 2023 22:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854214#M37616</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-01-17T22:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYREG - Box Plot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854256#M37622</link>
      <description>&lt;P&gt;Yes, it is, but that didn't change the output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;VALUE 
yearfmt
				6 = "2009-2010"
				7 = "2011-2012"
				8 = "2013-2014"
				9 = "2015-2016"
				10 = "2017-2018";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyreg data=&amp;amp;dataset order=internal;
  	STRATUM sdmvstra;
 	CLUSTER sdmvpsu;
 	WEIGHT &amp;amp;weight;

/* HTN Prevalence by year */
/***********************************************************************************************************/                         
	class year (ref="2009-2010") sex ;
/* 	class sex; */

	model htn = year age_yrs sex  / solution clparm;
	lsmeans  year / pdiff=all adjust=tukey plots=(meanplot);&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   	format 
	htn					htn_fmt.
	race_dum_white
	race_dum_hisp
	race_dum_other		dummy_fmt.
	
	reg_use				reg_usefmt.
	sex					sexfmt.	
	year 				yearfmt.
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-01-17 at 8.46.23 PM.png" style="width: 687px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79473i932D331623EF17CE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-01-17 at 8.46.23 PM.png" alt="Screenshot 2023-01-17 at 8.46.23 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 04:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854256#M37622</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2023-01-18T04:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYREG - Box Plot</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854259#M37623</link>
      <description>&lt;P&gt;&amp;lt; If that doesn't fix your problem, there are other tricks/techniques we can use.&amp;gt;&lt;/P&gt;
&lt;P&gt;It didn't, but thanks for the suggestion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like SAS just puts whatever value I put in the REF= option in the CLASS statement last, in both the LSMEANS table and the plot.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-01-17 at 8.56.21 PM.png" style="width: 669px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79474iB4052E82B2A4322F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-01-17 at 8.56.21 PM.png" alt="Screenshot 2023-01-17 at 8.56.21 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I can just change the reference level to the last value of year&amp;nbsp;(i.e., REF= "2017-2018") instead of the first &amp;nbsp;&amp;nbsp;(i.e., REF= "2009-2010"). That solves the problem. I don't think the reference level matters in this particular situation since I am really just looking for the adjusted means.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CLASS year (ref="2017-2019") sex ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-01-17 at 8.59.18 PM.png" style="width: 686px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79475iD8590F65A6463ED0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-01-17 at 8.59.18 PM.png" alt="Screenshot 2023-01-17 at 8.59.18 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 04:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SURVEYREG-Box-Plot/m-p/854259#M37623</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2023-01-18T04:59:41Z</dc:date>
    </item>
  </channel>
</rss>

