<?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: SAS Macro (Welch ANOVA vs Regular ANOVA) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906360#M357886</link>
    <description>&lt;P&gt;How will we recognize a "correct result"?&lt;/P&gt;
&lt;P&gt;We don't have your result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"The code is not giving me what I want." is not a very clear description of what you do want.&lt;/P&gt;
&lt;P&gt;Pvalue less than 0.05 for which exact test? The code you are showing appears to be attempting to run multiple ANOVA with different result variables. So I am not sure which specific Pvalue you are intending.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest that you set OPTIONS MPRINT; and then run your macro and read the log as to the generated statements.&lt;/P&gt;
&lt;P&gt;I strongly suspect that you have a timing issue of where in your code you compare the "largestpvalue" to when it is assigned.&lt;/P&gt;
&lt;P&gt;Also there can be some issues with comparisons to values like 0.05 if you do not take care to use something like %sysevalf to make sure that a decimal comparison is performed and not a text comparison.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post code into a text box or code box, opened with the &amp;lt;/&amp;gt; and "running man" icons respectively to maintain code indents and such. Your code is a bit hard to follow without them and the forum software will reformat text not pasted into one of those boxes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an aside when "looping" over a list I find an explicit loop like:&lt;/P&gt;
&lt;P&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;list));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %let value = %scan(&amp;amp;list,&amp;amp;i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a bit easier to follow and get the timing correct than a %do %until loop as you show for the "outcomes".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Dec 2023 22:21:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-12-05T22:21:25Z</dc:date>
    <item>
      <title>SAS Macro (Welch ANOVA vs Regular ANOVA)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906324#M357868</link>
      <description>&lt;P&gt;Hey Everyone,&lt;/P&gt;&lt;P&gt;I am trying to create a macro variable where I perform a One-Way ANOVA. If the pvalue for the test of equal variance is less than 0.05 then do a welch anova.&amp;nbsp; Note: I have not included the "else" part of the statement as yet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro group3(dsn,class,outcome);&lt;BR /&gt;%let largestpvalue=;&lt;BR /&gt;%if &amp;amp;largestpvalue le 0.05 %then %do;&lt;BR /&gt;%let i=1;&lt;BR /&gt;%let alloutcome=%scan(&amp;amp;outcome,&amp;amp;i);&lt;BR /&gt;%let myoutcome=;&lt;BR /&gt;%do %until (&amp;amp;alloutcome eq );&lt;BR /&gt;%put &amp;amp;largestpvalue;&lt;BR /&gt;%let myoutcome=&amp;amp;myoutcome &amp;amp;alloutcome;&lt;BR /&gt;title "&amp;amp;alloutcome.";&lt;BR /&gt;proc glm data=&amp;amp;dsn;&lt;BR /&gt;class &amp;amp;class;&lt;BR /&gt;model &amp;amp;alloutcome=&amp;amp;class;&lt;BR /&gt;ods output HovFTest=&amp;amp;alloutcome.;&lt;BR /&gt;means &amp;amp;class/hovtest=levene(type=abs) welch;&lt;BR /&gt;lsmeans &amp;amp;class;&lt;BR /&gt;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;select round(max(probF),.0001) as largestpvalue&lt;BR /&gt;into:largestpvalue&lt;BR /&gt;from &amp;amp;alloutcome.;&lt;BR /&gt;quit;title;&lt;BR /&gt;%let i=%eval(&amp;amp;i+1);&lt;BR /&gt;%let alloutcome=%scan(&amp;amp;outcome,&amp;amp;i);&lt;BR /&gt;%put &amp;amp;myoutcome;&lt;BR /&gt;%end;%end;&lt;BR /&gt;%mend group3;&lt;BR /&gt;%group3(sashelp.iris,species,Sepallength sepalwidth Petallength petalwidth);&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 20:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906324#M357868</guid>
      <dc:creator>Reader587</dc:creator>
      <dc:date>2023-12-05T20:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro (Welch ANOVA vs Regular ANOVA)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906331#M357872</link>
      <description>&lt;P&gt;What are you asking for help&amp;nbsp; with?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 21:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906331#M357872</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-05T21:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro (Welch ANOVA vs Regular ANOVA)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906351#M357882</link>
      <description>&lt;P&gt;I am asking for help with getting the correct result. The code is not giving me what I want. I want to do Welch ANOVA only when the pvalue is less than 0.05 (The pvalue for the test of equal variance).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 21:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906351#M357882</guid>
      <dc:creator>Reader587</dc:creator>
      <dc:date>2023-12-05T21:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro (Welch ANOVA vs Regular ANOVA)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906360#M357886</link>
      <description>&lt;P&gt;How will we recognize a "correct result"?&lt;/P&gt;
&lt;P&gt;We don't have your result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"The code is not giving me what I want." is not a very clear description of what you do want.&lt;/P&gt;
&lt;P&gt;Pvalue less than 0.05 for which exact test? The code you are showing appears to be attempting to run multiple ANOVA with different result variables. So I am not sure which specific Pvalue you are intending.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest that you set OPTIONS MPRINT; and then run your macro and read the log as to the generated statements.&lt;/P&gt;
&lt;P&gt;I strongly suspect that you have a timing issue of where in your code you compare the "largestpvalue" to when it is assigned.&lt;/P&gt;
&lt;P&gt;Also there can be some issues with comparisons to values like 0.05 if you do not take care to use something like %sysevalf to make sure that a decimal comparison is performed and not a text comparison.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post code into a text box or code box, opened with the &amp;lt;/&amp;gt; and "running man" icons respectively to maintain code indents and such. Your code is a bit hard to follow without them and the forum software will reformat text not pasted into one of those boxes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an aside when "looping" over a list I find an explicit loop like:&lt;/P&gt;
&lt;P&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;list));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %let value = %scan(&amp;amp;list,&amp;amp;i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a bit easier to follow and get the timing correct than a %do %until loop as you show for the "outcomes".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 22:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906360#M357886</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-05T22:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro (Welch ANOVA vs Regular ANOVA)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906363#M357887</link>
      <description>&lt;P&gt;If you code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;largestpvalue le 0.05 %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the macro language will use call %EVAL() to evaluate the expression, and because %EVAL does not know about decimal points it will do a text comparison.&amp;nbsp; Since you want to do a numeric comparison, one improvement would be to explicitly call %SYSEVALF:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysevalf(&amp;amp;largestpvalue le 0.05) %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But there may be other issues as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 22:41:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Welch-ANOVA-vs-Regular-ANOVA/m-p/906363#M357887</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-12-05T22:41:01Z</dc:date>
    </item>
  </channel>
</rss>

