<?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 How do I script a for loop to run oneway ANOVA over all Y columns in a data table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361397#M61100</link>
    <description>&lt;P&gt;I have a large data table with 10,000 different column names and a small number of rows containing replicates from 5 different sample groups, including a control group labeled "HN30".&amp;nbsp; I have a script that will run a one way ANOVA and Dunnett post-hoc mean comparisons test (i.e. Means comparison) to the control group (HN30) if I specify each Y variable one at a time. However, I don't want to type in all 10,000 different column names or be prompted to run a Dunnett test or enter the control name for every column analysis.&amp;nbsp; &amp;nbsp;Can someone help me write a for loop that will iterate the commands through all columns one a at a time. Once I get the output, I know how to use the combine tables command to merge all the output P-values.&amp;nbsp; Below is what I have that works for two specified columns named "SPP1", and "ABCC2" where control group rows are labeled "HN30".&amp;nbsp; Just need to iterate across all columns. Thanks so much !&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Fit Group(
	Oneway(
		Y( :SPP1 ),
		X( :Cell lline ),
		With Control( 1, {"HN30"} ),
		Comparison Circles( 1 ),
		SendToReport(
			Dispatch(
				{"Means Comparisons",
				"Comparisons with a control using Dunnett's Method",
				"LSD Threshold Matrix"},
				"p-Value",
				NumberColBox,
				{Set Format( "Fixed Dec", 15, 15 )}
			)
		)
	),
	Oneway(
		Y( :ABCC2 ),
		X( :Cell lline ),
		With Control( 1, {"HN30"} ),
		Comparison Circles( 1 ),
		SendToReport(
			Dispatch(
				{"Means Comparisons",
				"Comparisons with a control using Dunnett's Method",
				"LSD Threshold Matrix"},
				"p-Value",
				NumberColBox,
				{Set Format( "Fixed Dec", 15, 15 )}
			)
		)
	),
	&amp;lt;&amp;lt;{Arrange in Rows( 1 )}
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Jun 2023 22:06:38 GMT</pubDate>
    <dc:creator>Mitch</dc:creator>
    <dc:date>2023-06-09T22:06:38Z</dc:date>
    <item>
      <title>How do I script a for loop to run oneway ANOVA over all Y columns in a data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361397#M61100</link>
      <description>&lt;P&gt;I have a large data table with 10,000 different column names and a small number of rows containing replicates from 5 different sample groups, including a control group labeled "HN30".&amp;nbsp; I have a script that will run a one way ANOVA and Dunnett post-hoc mean comparisons test (i.e. Means comparison) to the control group (HN30) if I specify each Y variable one at a time. However, I don't want to type in all 10,000 different column names or be prompted to run a Dunnett test or enter the control name for every column analysis.&amp;nbsp; &amp;nbsp;Can someone help me write a for loop that will iterate the commands through all columns one a at a time. Once I get the output, I know how to use the combine tables command to merge all the output P-values.&amp;nbsp; Below is what I have that works for two specified columns named "SPP1", and "ABCC2" where control group rows are labeled "HN30".&amp;nbsp; Just need to iterate across all columns. Thanks so much !&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Fit Group(
	Oneway(
		Y( :SPP1 ),
		X( :Cell lline ),
		With Control( 1, {"HN30"} ),
		Comparison Circles( 1 ),
		SendToReport(
			Dispatch(
				{"Means Comparisons",
				"Comparisons with a control using Dunnett's Method",
				"LSD Threshold Matrix"},
				"p-Value",
				NumberColBox,
				{Set Format( "Fixed Dec", 15, 15 )}
			)
		)
	),
	Oneway(
		Y( :ABCC2 ),
		X( :Cell lline ),
		With Control( 1, {"HN30"} ),
		Comparison Circles( 1 ),
		SendToReport(
			Dispatch(
				{"Means Comparisons",
				"Comparisons with a control using Dunnett's Method",
				"LSD Threshold Matrix"},
				"p-Value",
				NumberColBox,
				{Set Format( "Fixed Dec", 15, 15 )}
			)
		)
	),
	&amp;lt;&amp;lt;{Arrange in Rows( 1 )}
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:06:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361397#M61100</guid>
      <dc:creator>Mitch</dc:creator>
      <dc:date>2023-06-09T22:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I script a for loop to run oneway ANOVA over all Y columns in a data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361436#M61106</link>
      <description>&lt;P&gt;Here is one example for a loop. Probably you can adapt to your needs.&lt;/P&gt;&lt;P&gt;You can find examples for the used commands in scripting index or in scripting reference, if needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

cdt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

all_ys = cdt &amp;lt;&amp;lt; get column names( Continuous, String );

For( i = 1, i &amp;lt;= n items(all_ys), i++,
	Eval( Parse( Eval Insert( "oneway( X( :SITE ), Y( :^all_ys[i]^ ) )" ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2021 18:58:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361436#M61106</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2021-02-22T18:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I script a for loop to run oneway ANOVA over all Y columns in a data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361465#M61108</link>
      <description>&lt;P&gt;Thanks Georg,&lt;/P&gt;&lt;P&gt;I adapted your example to my specific table and now get all the One Way ANOVAs running for each column, so that part works.&amp;nbsp; However, I still cannot figure out&amp;nbsp; how to work in the Dunnett test to follow each ANOVA.&amp;nbsp; Not sure how to structure that subcommand with the for loop.&amp;nbsp; Here is what I have so far, but I cannot the specific Dunnett tests that I show at the bottom to run in the for loop.&amp;nbsp; Any ideas?&amp;nbsp; Thanks again&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
cdt = Open( "F:/Stats/DTest.jmp" );

all_ys = cdt &amp;lt;&amp;lt; get column names( Continuous, String );

For( i = 1, i &amp;lt;= n items(all_ys), i++,
	Eval( Parse( Eval Insert( "oneway( X( :Cell lLine ), Y( :^all_ys[i]^ ) )" ) ) )
);

	

Fit Group(
	Oneway(
		Y( :SPP1 ),
		X( :Cell lline ),
		With Control( 1, {"HN30"} ),
		Comparison Circles( 1 ),
		SendToReport(
			Dispatch(
				{"Means Comparisons",
				"Comparisons with a control using Dunnett's Method",
				"LSD Threshold Matrix"},
				"p-Value",
				NumberColBox,
				{Set Format( "Fixed Dec", 15, 15 )}
			)
		)
	),
	Oneway(
		Y( :ABCC2 ),
		X( :Cell lline ),
		With Control( 1, {"HN30"} ),
		Comparison Circles( 1 ),
		SendToReport(
			Dispatch(
				{"Means Comparisons",
				"Comparisons with a control using Dunnett's Method",
				"LSD Threshold Matrix"},
				"p-Value",
				NumberColBox,
				{Set Format( "Fixed Dec", 15, 15 )}
			)
		)
	),
	&amp;lt;&amp;lt;{Arrange in Rows( 1 )}
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2021 20:43:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361465#M61108</guid>
      <dc:creator>Mitch</dc:creator>
      <dc:date>2021-02-22T20:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I script a for loop to run oneway ANOVA over all Y columns in a data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361503#M61110</link>
      <description>&lt;P&gt;you can try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

cdt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

ow_expr = Expr(
	Oneway(
		Y( Column( all_ys[i] ) ),
		X( :SITE ),
		/* 3rd site is control */
		With Control( 1, {3} ),
		Comparison Circles( 1 ),
		SendToReport(
			Dispatch(
				{"Means Comparisons", "Comparisons with a control using Dunnett's Method", "LSD Threshold Matrix"},
				"p-Value",
				NumberColBox,
				{Set Format( "Fixed Dec", 15, 15 )}
			)
		)

	)
);

all_ys = cdt &amp;lt;&amp;lt; get column names( Continuous, String );

//For( i = 1, i &amp;lt;= n items(all_ys), i++,
For( i = 1, i &amp;lt;= 3, i++,
	Eval( Substitute( ow_expr, Expr( i ), i ) );
//	Eval( Substitute( Expr( oneway( X( :SITE ), Y( Column( all_ys[i] ) ) ) ), Expr( i ), i ) )
//	Eval( Parse( Eval Insert( "oneway( X( :SITE ), Y( :^all_ys[i]^ ) )" ) ) )	
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2021 21:49:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361503#M61110</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2021-02-22T21:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I script a for loop to run oneway ANOVA over all Y columns in a data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361525#M61112</link>
      <description>&lt;P&gt;Thanks so much for all your time.&amp;nbsp; Your solution works and is almost perfect.&amp;nbsp; I appreciate all the time you spent helping.&amp;nbsp; Just wondering if there is a command or syntax change that would force all the outputs from the loop to stay in just one window.&amp;nbsp; Right now, every loop makes its own window so I will have thousands of windows popping open.&amp;nbsp; Also, I cannot use the combine data table command to collate similar analyses because each result is in a separate windows.&amp;nbsp; Below is my code using your last suggestion. Obviously, I have no clue myself how to code.&amp;nbsp; Any ideas to get them all to output to the same window?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
cdt = Open( "F:/Stats/DTest.jmp" );

ow_expr = Expr(
	Oneway(
		Y( Column( all_ys[i] ) ),
		X( :Cell lline ),
		/* 3rd site is control */
		With Control( 1, {"HN30"} ),
		Comparison Circles( 1 ),
		SendToReport(
			Dispatch(
				{"Means Comparisons", "Comparisons with a control using Dunnett's Method", "LSD Threshold Matrix"},
				"p-Value",
				NumberColBox,
				{Set Format( "Fixed Dec", 15, 15 )}
			)
		)

	)
);

all_ys = cdt &amp;lt;&amp;lt; get column names( Continuous, String );

//For( i = 1, i &amp;lt;= n items(all_ys), i++,
For( i = 1, i &amp;lt;= n items(all_ys), i++,
	Eval( Substitute( ow_expr, Expr( i ), i ) );
//	Eval( Substitute( Expr( oneway( X( :Cell lline ), Y( Column( all_ys[i] ) ) ) ), Expr( i ), i ) )
//	Eval( Parse( Eval Insert( "oneway( X( :Cell lline ), Y( :^all_ys[i]^ ) )" ) ) )	
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2021 22:21:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-script-a-for-loop-to-run-oneway-ANOVA-over-all-Y/m-p/361525#M61112</guid>
      <dc:creator>Mitch</dc:creator>
      <dc:date>2021-02-22T22:21:55Z</dc:date>
    </item>
  </channel>
</rss>

