<?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: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821415#M100053</link>
    <description>&lt;P&gt;Column() refers to the column object, and As Column() refers to the value of that column in the current Row().&lt;/P&gt;</description>
    <pubDate>Mon, 09 Dec 2024 21:29:13 GMT</pubDate>
    <dc:creator>mmarchandFSLR</dc:creator>
    <dc:date>2024-12-09T21:29:13Z</dc:date>
    <item>
      <title>Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821171#M100017</link>
      <description>&lt;P&gt;I have an exported CSV that was formed from two or more different sources that have slightly different column names.&lt;/P&gt;&lt;P&gt;No row has data in more than one of those columns. Like on the screenshot below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024-12-06 19_43_09-Untitled 7 - JMP.png" style="width: 184px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/70951iFA041427964B44ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2024-12-06 19_43_09-Untitled 7 - JMP.png" alt="2024-12-06 19_43_09-Untitled 7 - JMP.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I combine all of them into one column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One idea is to use&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Combine Columns()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which will result in a Multiple Response column, but since data is non-intersecting, it will be just one number throughout the column. Then force data type to Numeric and modeling type to Continuous. But it produces warning\error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any cleaner way to do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2024 03:51:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821171#M100017</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2024-12-07T03:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821182#M100019</link>
      <description>&lt;P&gt;I would handle it this way&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
For Each Row(
	:AA bb = Sum( :AA bb, :AA_bb_ )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using the Sum() function ignores missing values, so you will get the values you want.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2024 05:41:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821182#M100019</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-12-07T05:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821385#M100048</link>
      <description>&lt;P&gt;Jim,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;I'm going to use this solution.&lt;/P&gt;&lt;P&gt;I'm trying to script it now so that the column names are not hardcoded.&lt;/P&gt;&lt;P&gt;I'm not quite sure why I'm getting error on this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each Row(
	Column("AA bb") = 1234;
	//Sum( :AA bb, :AA _bb_ )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Error is:&lt;/P&gt;&lt;P&gt;attempting to assign to an object that is not an L-value at row 1 in access or evaluation of 'Assign' , Column( "AA bb" ) = /*###*/1234 /*###*/&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 18:27:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821385#M100048</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2024-12-09T18:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821387#M100049</link>
      <description>&lt;P&gt;Idea is to write a function and feed a dictionary to that function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like 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 );
dt = Current Data Table();
dict = {"AA bb", "AA _bb_"};

For Each Row(
	Column(dict[1]) = Sum( Column(dict[1]), Column(dict[2]) )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Only this variant gives the following error:&lt;/P&gt;&lt;P&gt;need arguments to be scalars, matrices, or lists at row 1 in access or evaluation of 'Sum' , Sum/*###*/(Column( dict[1] ), Column( dict[2] ))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could never wrap my head round the fact that sometimes Column() works as expected, sometimes it doesn't. Sometimes I need to use As Column(). Sometimes something else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S. As Column() worked. Can somebody explain the difference between Column() and As Column()?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 18:36:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821387#M100049</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2024-12-09T18:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821400#M100051</link>
      <description>&lt;P&gt;Ok, my final snippet of code it here:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
dict = {"AA bb", "AA _bb_"};

sumExpr = Expr( Sum() );
For Each( {value, index}, dict,
	Insert Into( sumExpr, Name Expr( As Column( value ) ) )
);
	
Eval(
	Substitute(
			Expr(
				For Each Row(
					As Column( dict[1] ) = placeholder
				)
			),
		Expr( placeholder ), Name Expr( sumExpr )
	)
);
	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any way to improve it?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 20:38:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821400#M100051</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2024-12-09T20:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821414#M100052</link>
      <description>&lt;P&gt;It's a little more complicated than needed.&amp;nbsp; This code works, too, without too much thinking.&amp;nbsp; It will accept more than two column names, in case that's desired.&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 );
dt = Current Data Table();
dict = {"AA bb", "AA _bb_"};
For Each Row( dt,
	As Column(dict[1]) = Sum( Transform Each( {v, i}, dict, As Column( v ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Dec 2024 21:26:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821414#M100052</guid>
      <dc:creator>mmarchandFSLR</dc:creator>
      <dc:date>2024-12-09T21:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821415#M100053</link>
      <description>&lt;P&gt;Column() refers to the column object, and As Column() refers to the value of that column in the current Row().&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 21:29:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821415#M100053</guid>
      <dc:creator>mmarchandFSLR</dc:creator>
      <dc:date>2024-12-09T21:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821573#M100062</link>
      <description>&lt;P&gt;My next iteration accounts for a case when column name is present in the dictionary, but not present in the table:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
dict = {"AA bb", "AA _bb_", "AA cc"};


sumExpr = Expr( Sum() );
For Each( {value, index}, dict,
	If( Try( Column( value ) &amp;lt;&amp;lt; Get Name, "nocolumn" ) != "nocolumn", 
		Insert Into( sumExpr, Name Expr( As Column( value ) ) )
	)
);

Name Expr(sumExpr);
Try(	
Eval(
	Substitute(
			Expr(
				For Each Row(
					As Column( dict[1] ) = placeholder
				)
			),
		Expr( placeholder ), Name Expr( sumExpr )
	)
),
Write("No columns found")
)
	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How would you do that when using Transform Each?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 03:40:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821573#M100062</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2024-12-10T03:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821642#M100075</link>
      <description>Try using concatenate tool :&lt;BR /&gt;&lt;BR /&gt;Create a new column that will include both variables&lt;BR /&gt;&lt;BR /&gt;Right-click on the column&lt;BR /&gt;Select Formula to open the Formula Editor.&lt;BR /&gt;&lt;BR /&gt;In the Formula Editor, go to the Functions list on the left.&lt;BR /&gt;Under Character, find and select Concatenate.&lt;BR /&gt;&lt;BR /&gt;Drag or select the first column into the first argument box of the Concatenate function.&lt;BR /&gt;Drag or select the second column into the next argument box.&lt;BR /&gt;&lt;BR /&gt;Click OK or Apply to create the new combined column.&lt;BR /&gt;</description>
      <pubDate>Tue, 10 Dec 2024 13:45:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821642#M100075</guid>
      <dc:creator>Samira</dc:creator>
      <dc:date>2024-12-10T13:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Data cleanup: How to combine several columns with slightly different names and non-intersecting data into one?</title>
      <link>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821777#M100091</link>
      <description>&lt;P&gt;I would just add a Try().&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 );
dt = Current Data Table();
dict = {"AA bb", "AA _bb_", "AA cc"};
For Each Row( dt, As Column( dict[1] ) = Sum( Transform Each( {v, i}, dict, Try( As Column( v ), . ) ) ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Dec 2024 16:44:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-cleanup-How-to-combine-several-columns-with-slightly/m-p/821777#M100091</guid>
      <dc:creator>mmarchandFSLR</dc:creator>
      <dc:date>2024-12-10T16:44:10Z</dc:date>
    </item>
  </channel>
</rss>

