<?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: column switcher function in script only reports first variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/624170#M82301</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've provided the final script for the column switcher function to provide concatenated data tables.&amp;nbsp; I did get some help from JMP Support on how to concatenate the tables. Hope this is helpful to others.&lt;/P&gt;&lt;P&gt;Annabelle&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2023 11:49:38 GMT</pubDate>
    <dc:creator>aromd</dc:creator>
    <dc:date>2023-04-20T11:49:38Z</dc:date>
    <item>
      <title>column switcher function in script only reports first variable</title>
      <link>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/622595#M82158</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;The following script returns one output report with the first variable for switching (Two_deoxyuridine) but not the others in the switch list.&amp;nbsp; I've looked for a solution in the Scripting Index, YouTube videos, JMP community, and reading chapters in Jump into JMP.&amp;nbsp; Is the solution to insert a For Loop?&amp;nbsp; I'm using JMP17.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate any and all help,&lt;/P&gt;
&lt;P&gt;Annabelle&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;obj = dt &amp;lt;&amp;lt; Fit Model(
	Y( :dthtt ),
	Effects(
		:race1c, :age2c, :gender1, :APOE_INT, :Two_Deoxyuridine_INT,
		:APOE_INT * :Two_Deoxyuridine_INT
	),
	Personality( "Proportional Hazard" ),
	Censor( :dth ),
	Censor Code( "0" ),
	Run( Likelihood Ratio Tests( 0 ) )
);
ColumnSwitcherObject = obj &amp;lt;&amp;lt; Column Switcher(
	:Two_Deoxyuridine_INT,
	{:One_5_Anhydroglucitol_INT, :Two_Deoxyuridine_INT, :Two_Hydroxybutyric acid_INT,
	:Two_Hydroxyglutaric acid_INT}
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:07:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/622595#M82158</guid>
      <dc:creator>aromd</dc:creator>
      <dc:date>2023-06-09T16:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: column switcher function in script only reports first variable</title>
      <link>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/622623#M82160</link>
      <description>&lt;P&gt;I'm not exactly sure what is the question. My example seems to be working fine (or I might be missing something)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Job Satisfaction.jmp");
obj = dt &amp;lt;&amp;lt; Fit Model(
	Y(:Satisfaction_Avg),
	Effects(
		:Support_L, :Goal_L, :Work_L, :Interact_L, :Person_C,
		:Interact_L * :Person_C
	),
	Personality( "Proportional Hazard" ),
	Emphasis("Effect Leverage"),
	Run(
		:Satisfaction_Avg &amp;lt;&amp;lt; {Summary of Fit(1), Analysis of Variance(1),
		Parameter Estimates(1), Scaled Estimates(0), Plot Actual by Predicted(1),
		Plot Regression(0), Plot Residual by Predicted(1),
		Plot Studentized Residuals(0), Plot Effect Leverage(1),
		Plot Residual by Normal Quantiles(0), Box Cox Y Transformation(0)}
	)
);

col_switcher = obj &amp;lt;&amp;lt; Column Switcher(
	:Person_C,
	{:Person_C, :Intra_C, :Inter_C, General_S}
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1681493366528.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51983iF0B6005A9457CDC6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1681493366528.png" alt="jthi_0-1681493366528.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1681493375882.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51984i5B6190CE74ABDFBC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1681493375882.png" alt="jthi_1-1681493375882.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 17:30:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/622623#M82160</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-04-14T17:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: column switcher function in script only reports first variable</title>
      <link>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/622629#M82162</link>
      <description>&lt;P&gt;Thank you jthi for the quick reply.&amp;nbsp; I incorporated your script into mine and got the same problem.&amp;nbsp; The output table only contains results for Two_Deoxyuridine but not the other variables in the switch list.&amp;nbsp; I did run your script and it works as expected.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas where I'm going wrong with this script?&lt;/P&gt;
&lt;P&gt;Annabelle&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;obj = dt &amp;lt;&amp;lt; Fit Model(
	Y( :dthtt ),
	Effects(
		:race1c, :PC1, :PC2, :PC3, :age2c, :gender1, :bmi2c.x, :chol2.x, :curalc2.x, :pkyrs2c.x, :dbp2c.x,
		:sbp2c.x, :creatin1.x, :glucos2c.x, :APOE_INT, :Two_Deoxyuridine_INT,
		:APOE_INT * :Two_Deoxyuridine_INT
	),
	Personality( "Proportional Hazard" ),
	Emphasis( "Effect Leverage" ),
	Censor( :dth ),
	Censor Code( "0" ),
	Run(
		:dthtt &amp;lt;&amp;lt; {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ), Plot Effect Leverage( 1 ),
		Plot Residual by Normal Quantiles( 0 ), Box Cox Y Transformation( 0 )}
	)
);
ColumnSwitcherObject = obj &amp;lt;&amp;lt; Column Switcher(
	:Two_Deoxyuridine_INT,
	{:One_5_Anhydroglucitol_INT, :Two_Deoxyuridine_INT,
	:Two_Hydroxybutyric acid_INT, :Two_Hydroxyglutaric acid_INT,
	:Two_ketoisovaleric acid_INT, :Three_Hydroxybutyric acid_INT, :Five_MTHF_INT, &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Apr 2023 11:07:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/622629#M82162</guid>
      <dc:creator>aromd</dc:creator>
      <dc:date>2023-04-19T11:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: column switcher function in script only reports first variable</title>
      <link>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/622639#M82163</link>
      <description>&lt;P&gt;Addendum:&amp;nbsp; I was hoping the Column Switcher function would generate new Effect Summary tables with each variable.&amp;nbsp; The script works well with the first variable and then you can manually scroll through the Column Switcher to look at the other variables.&amp;nbsp; I want to NOT have to manually scroll through the list.&amp;nbsp; Is this possible?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 18:55:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/622639#M82163</guid>
      <dc:creator>aromd</dc:creator>
      <dc:date>2023-04-14T18:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: column switcher function in script only reports first variable</title>
      <link>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/623773#M82264</link>
      <description>&lt;P&gt;I'm making progress!&amp;nbsp; My main objective is to get a Effect Wald Test data table after every column switch. Eventually I will concatenate these tables.&amp;nbsp; The code below automatically starts the column switcher (this can be seen in the log) and does produce the Effect Wald Test data table but only for the first entry in the column switcher.&amp;nbsp; Any ideas on how to get the Effect Wald Test data table from each column when it switches?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;obj = dt &amp;lt;&amp;lt; Fit Model(
	Y( :dthtt ),
	Effects(
		:race1c, :PC1, :PC2, :PC3, :age2c, :gender1, :bmi2c.x, :chol2.x, :curalc2.x, :pkyrs2c.x, :dbp2c.x,
		:sbp2c.x, :creatin1.x, :glucos2c.x, :APOE_INT, :One_5_Anhydroglucitol_INT,
		:APOE_INT * :One_5_Anhydroglucitol_INT
	),
	Personality( "Proportional Hazard" ),
	Censor( :dth ),
	Censor Code( "0" ),
	Run(
		:dthtt &amp;lt;&amp;lt; {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ),
		Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ), Plot Effect Leverage( 1 ),
		Plot Residual by Normal Quantiles( 0 ), Box Cox Y Transformation( 0 )}
	)
);

ColumnSwitcher = obj &amp;lt;&amp;lt; Column Switcher(
	:One_5_Anhydroglucitol_INT,
	{:One_5_Anhydroglucitol_INT, :Two_Deoxyuridine_INT, :Two_Hydroxybutyric acid_INT,
	:Two_Hydroxyglutaric acid_INT, :Dummy variable_INT}
);

 

pre = Function( {currentColumn, nextColumn, switcher},
	Print(
		"Before switch: " || (currentColumn &amp;lt;&amp;lt; get name) || " &amp;gt;&amp;gt; " || (nextColumn &amp;lt;&amp;lt; get name) ||
		" [Column Switcher] current: " || (columnSwitcher &amp;lt;&amp;lt; Get Current)
	);
	If( nextColumn &amp;lt;&amp;lt; get name == "Dummy variable_INT",
		0,
		1
	);
);
post = Function( {previousColumn, currentColumn, switcher},
	Print(
		"After switch: " || (previousColumn &amp;lt;&amp;lt; get name) || " &amp;gt;&amp;gt; " || (currentColumn &amp;lt;&amp;lt; get name) ||
		" [Column Switcher] current: " || (columnSwitcher &amp;lt;&amp;lt; Get Current)
	)
);
columnSwitcher &amp;lt;&amp;lt; Make Column Switch Handler( pre, post );
ColumnSwitcher &amp;lt;&amp;lt; Set Script(
	obj = Data Table( "MESA 2018Events_Exam2Main_Proteomics_Metabolomics_MARCH 13 2023" ) &amp;lt;&amp;lt;
	Fit Model(
		Y( :dthtt ),
		Effects(
			:race1c, :PC1, :PC2, :PC3, :age2c, :gender1, :bmi2c.x, :chol2.x, :curalc2.x, :pkyrs2c.x, :dbp2c.x,
			:sbp2c.x, :creatin1.x, :glucos2c.x, :APOE_INT, :One_5_anhydroglucitol_INT,
			:APOE_INT * :One_5_anhydroglucitol_INT
		),
		Personality( "Proportional Hazard" ),
		Censor( :dth ),
		Censor Code( "0" ),
		Run( Likelihood Ratio Tests( 0 ) ),
		Column Switcher(
			:One_5_anhydroglucitol_INT,
			{:One_5_Anhydroglucitol_INT, :Two_Deoxyuridine_INT, :Two_Hydroxybutyric acid_INT,
			:Two_Hydroxyglutaric acid_INT, :Dummy variable_INT}
		)
	);
	Report( obj )["Effect Wald Tests", Table Box( 1 )] &amp;lt;&amp;lt; Make Into Data Table;
	obj &amp;lt;&amp;lt; Close Window;
);

ColumnSwitcher &amp;lt;&amp;lt; Run;
Wait( 5/*seconds, while it animates*/ );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Apr 2023 11:09:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/623773#M82264</guid>
      <dc:creator>aromd</dc:creator>
      <dc:date>2023-04-19T11:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: column switcher function in script only reports first variable</title>
      <link>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/623819#M82266</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I solved my problem and the script is attached.&amp;nbsp; One tip was to place a dummy variable column in the main table and to place it after the final variable for the column switch.&amp;nbsp; This allowed the column switch to work appropriately.&amp;nbsp; My next step is to concatenate all of the Effect Wald Tests data tables, and I don't think that should be difficult.&amp;nbsp; I hope this script is useful to others in the community.&lt;/P&gt;&lt;P&gt;Annabelle&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 12:25:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/623819#M82266</guid>
      <dc:creator>aromd</dc:creator>
      <dc:date>2023-04-19T12:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: column switcher function in script only reports first variable</title>
      <link>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/624170#M82301</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've provided the final script for the column switcher function to provide concatenated data tables.&amp;nbsp; I did get some help from JMP Support on how to concatenate the tables. Hope this is helpful to others.&lt;/P&gt;&lt;P&gt;Annabelle&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 11:49:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-switcher-function-in-script-only-reports-first-variable/m-p/624170#M82301</guid>
      <dc:creator>aromd</dc:creator>
      <dc:date>2023-04-20T11:49:38Z</dc:date>
    </item>
  </channel>
</rss>

