<?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: While looping, extracting column name from list and adding it to report table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/While-looping-extracting-column-name-from-list-and-adding-it-to/m-p/800514#M97614</link>
    <description>&lt;P&gt;If you are setting same value to each of the rows you can use &lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/column-messages.shtml?os=win&amp;amp;source=application#ww1920058" target="_blank" rel="noopener"&gt;set each value&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
mystr = "ABC";
dt &amp;lt;&amp;lt; New Column("X", Character, Set Each Value(mystr));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2024 19:12:37 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-09-19T19:12:37Z</dc:date>
    <item>
      <title>While looping, extracting column name from list and adding it to report table</title>
      <link>https://community.jmp.com/t5/Discussions/While-looping-extracting-column-name-from-list-and-adding-it-to/m-p/800504#M97613</link>
      <description>&lt;P&gt;I'm working on a script that loops through a list of Y responses and runs degradation (stability test) on each before outputting parts of the report to a combined data table. It consists of the following steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Opens a dialog box where the user selects several "Y, response", the "Time", and the "label, system ID".&lt;/LI&gt;&lt;LI&gt;For each "Y, response", the script loops through and runs a degradation stability test, outputs the "Model Comparisons" information into a report.&lt;/LI&gt;&lt;LI&gt;Concatenates the reports into a master table.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I've included code to take the name of the y-column for each loop and add it as a new column to each report and then concatenate each report to a new master table. The individual reports and the 'combinedDataTable' both have the new column ("Source Y Column"); however, it does not populate the cells with the respective column name. The script runs fine and without errors. I've included a number of screenshots below. The problematic code is toward the end of the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Initialize an empty data table to store combined results
combinedDataTable = New Table( "Combined Degradation Data" );

// Loop through each selected Y column and perform degradation analysis
For( i = 1, i &amp;lt;= N Items( YCols ), i++,
	currentYCol = Column( dt, YCols[i] );

    // Calculate the min and max values of the current Y column
	minValue = Col Minimum( currentYCol );
	maxValue = Col Maximum( currentYCol );

    // Adjust the min and max values by 2%
	adjustedMin = minValue * 0.98;
	adjustedMax = maxValue * 1.02;

    // Determine the increment value based on the highest value
	If( maxValue &amp;lt; 5,
		incValue = 0.25,
		If( maxValue &amp;gt; 5 &amp;amp; maxValue &amp;lt; 15,
			incValue = 0.25,
			If( maxValue &amp;gt; 90,
				incValue = 0.5,
				incValue = (adjustedMax - adjustedMin) / 10
			)
		)
	);
	
	//Determine the X Scale Box Based on Number of Timepoints
	maxTimepoint = Col Maximum( Column( dt, XCols[1] ) );
	adjustedMaxTimepoint = maxTimepoint + 1;

    // Perform Degradation Analysis
	degReport = dt &amp;lt;&amp;lt; Degradation(
		Y( currentYCol ),
		Time( Column( dt, XCols[1] ) ), // Assuming only one X column is selected
		Label( Column( dt, BCols[1] ) ), // Assuming only one By column is selected
		Application( "Stability Test" ),
		Connect Data Markers( 0 ),
		Show Fitted Lines( 1 ),
		Show Spec Limits( 1 ),
		Show Median Curves( 0 ),
		Show Legend( 1 ),
		No Tab List( 0 ),
		Use Pooled MSE for Nonpoolable Model( 0 ),
		Set Censoring Time( . ),
		Show Residual Plot( 1 ),
		Show Inverse Prediction Plot( 1 ),
		Show Curve Interval( 1 ),
		Inverse Prediction Interval( "Confidence Interval" ),
		Inverse Prediction Alpha( 0.05 ),
		Inverse Prediction Side( "Lower One Sided" ),
		SendToReport(
			Dispatch( {"Overlay"}, "1", ScaleBox, {Min( -1 ), Max( adjustedMaxTimepoint ), Inc( 6 ), Minor Ticks( 1 )} ),
			Dispatch(
				{"Overlay"},
				"2",
				ScaleBox,
				{Format( "Fixed Dec", 12, 1 ), Min( adjustedMin ), Max( adjustedMax ), Inc( incValue ), Minor Ticks( 0 )}
			)
		)
	);
	 // Extract the data from the specified location
	extractedData = Report( degReport )["Degradation Data Analysis"]["Overlay"]["Stability Tests"][Table Box( 2 )] &amp;lt;&amp;lt; Make Combined Data Table;

    // Add a column to indicate the source Y column
	currentYColName = Column( dt, YCols[i] ) &amp;lt;&amp;lt; Get Name;
	extractedData &amp;lt;&amp;lt; New Column( "Source Y Column", Character, "Nominal", Set Values( Repeat( currentYColName, N Rows( extractedData ) ) ) );

    // Combine the extracted data into the combined data table
	combinedDataTable &amp;lt;&amp;lt; Concatenate( extractedData, Append to first table( 1 ) );
    
     // Close the individual report window
	Close( Window( degReport ) );
);

// Show the combined data table
combinedDataTable &amp;lt;&amp;lt; Show Window;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notes:&lt;BR /&gt;Here is the output window from one of the degradation analyses. I'm extract the information in the red outline.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ModelComparisons01_SS.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68468iE774DD4F7EC3777B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ModelComparisons01_SS.png" alt="ModelComparisons01_SS.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; Here is the master output table that has both Y, responses but the 'Source Y Column' is not populated.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Combined Degradation Data_SS.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68469iBAA75101BA42A991/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Combined Degradation Data_SS.png" alt="Combined Degradation Data_SS.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 19:04:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/While-looping-extracting-column-name-from-list-and-adding-it-to/m-p/800504#M97613</guid>
      <dc:creator>yaroslaw</dc:creator>
      <dc:date>2024-09-19T19:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: While looping, extracting column name from list and adding it to report table</title>
      <link>https://community.jmp.com/t5/Discussions/While-looping-extracting-column-name-from-list-and-adding-it-to/m-p/800514#M97614</link>
      <description>&lt;P&gt;If you are setting same value to each of the rows you can use &lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/column-messages.shtml?os=win&amp;amp;source=application#ww1920058" target="_blank" rel="noopener"&gt;set each value&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
mystr = "ABC";
dt &amp;lt;&amp;lt; New Column("X", Character, Set Each Value(mystr));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 19:12:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/While-looping-extracting-column-name-from-list-and-adding-it-to/m-p/800514#M97614</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-09-19T19:12:37Z</dc:date>
    </item>
  </channel>
</rss>

