<?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: Select and Delete a Column Where All Rows Have The Same Value in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Select-and-Delete-a-Column-Where-All-Rows-Have-The-Same-Value/m-p/62142#M33477</link>
    <description>&lt;P&gt;I would use the Summarize() function.&amp;nbsp; Here is a little sample on how to do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "Sample",
	Add Rows( 18 ),
	New Column("name",Character,
		"Nominal",
		Set Values(
			{"KATIE", "LOUISE", "JANE", "JACLYN", "LILLIE", "BARBARA", "ALICE", "SUSAN",
			"JUDY", "ELIZABETH", "LESLIE", "CAROL", "PATTY", "MARY", "AMY", "MARTHA",
			"MARION", "LINDA"}
		)
	),
	New Column( "age" ,Numeric,
		"Ordinal",
		Format( "Fixed Dec", 5, 0 ),
		Set Values(
			[12, 12, 12, 12, 12, ., 13, 13, 14, 14, 14, 14, 14, 15, 15, 16, 16, 17]
		)
	),
	New Column( "sex" ,Character( 1 ),
		"Nominal",
		Set Values(
			{"F", "F", "", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
			"F", "F", "F"}
		)
	),
	New Column(
		"height",
		Numeric,
		"Continuous",
		Format( "Fixed Dec", 5, 0 ),
		Set Values(
			[59, ., 55, 66, 52, 60, 61, 56, 61, 62, 65, 63, 62, 62, 64, 65, 60, 62]
		)
	),
	New Column("weight",
		Numeric,
		"Continuous",
		Format( "Fixed Dec", 5, 0 ),
		Set Values(
			[95, 123, 74, 145, 64, 112, 107, 67, 81, 91, 142, 84, 85, 92, 112, 112, 115,
			116]
		)
	),
	New Column( "allthesame",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] )
	),
	New Column( "allcharthesame",
		Character,
		"Nominal",
		Set Selected,
		Set Values(
			{"zippy", "zippy", "zippy", "zippy", "zippy", "zippy", "zippy", "zippy",
			"zippy", "zippy", "zippy", "zippy", "zippy", "zippy", "zippy", "zippy",
			"zippy", "zippy"}
		)
	),
	Set Row States( [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ),
	Set Label Columns( :name )
);

colNamesList = dt &amp;lt;&amp;lt; get column names( String );
colsToDeleteList = {};
For( i = 1, i &amp;lt;= N Items( colNamesList ), i++,
	Summarize( dt, bygroup = by( colNamesList[i] ) );
	If( N Items( bygroup ) == 1 | (N Items( bygroup ) == 2 &amp;amp; bygroup[1] == ""),
		Insert Into( colsToDeleteList, colNamesList[i] )
	);
);
Show( colsToDeleteList );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 03 Jul 2018 17:12:40 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-07-03T17:12:40Z</dc:date>
    <item>
      <title>Select and Delete a Column Where All Rows Have The Same Value</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-Delete-a-Column-Where-All-Rows-Have-The-Same-Value/m-p/62140#M33476</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working on an inherited script that outputs a pretty large data table. &amp;nbsp;I great number of the columns will have the same value in each row. &amp;nbsp;For example :Fred will all the rows =1 while :lucy will have all the rows = "yesterday". &amp;nbsp;These columns are not useful for further analysis so I would like to delete or hide them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Who would I script this? &amp;nbsp;I would like to review each column to see if every value is the same and if so delete it. &amp;nbsp;If some of the rows are empty, but other rows all contain the same value, the column should be kept.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any starting points?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 16:58:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-Delete-a-Column-Where-All-Rows-Have-The-Same-Value/m-p/62140#M33476</guid>
      <dc:creator>Hegedus</dc:creator>
      <dc:date>2018-07-03T16:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Select and Delete a Column Where All Rows Have The Same Value</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-Delete-a-Column-Where-All-Rows-Have-The-Same-Value/m-p/62142#M33477</link>
      <description>&lt;P&gt;I would use the Summarize() function.&amp;nbsp; Here is a little sample on how to do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "Sample",
	Add Rows( 18 ),
	New Column("name",Character,
		"Nominal",
		Set Values(
			{"KATIE", "LOUISE", "JANE", "JACLYN", "LILLIE", "BARBARA", "ALICE", "SUSAN",
			"JUDY", "ELIZABETH", "LESLIE", "CAROL", "PATTY", "MARY", "AMY", "MARTHA",
			"MARION", "LINDA"}
		)
	),
	New Column( "age" ,Numeric,
		"Ordinal",
		Format( "Fixed Dec", 5, 0 ),
		Set Values(
			[12, 12, 12, 12, 12, ., 13, 13, 14, 14, 14, 14, 14, 15, 15, 16, 16, 17]
		)
	),
	New Column( "sex" ,Character( 1 ),
		"Nominal",
		Set Values(
			{"F", "F", "", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
			"F", "F", "F"}
		)
	),
	New Column(
		"height",
		Numeric,
		"Continuous",
		Format( "Fixed Dec", 5, 0 ),
		Set Values(
			[59, ., 55, 66, 52, 60, 61, 56, 61, 62, 65, 63, 62, 62, 64, 65, 60, 62]
		)
	),
	New Column("weight",
		Numeric,
		"Continuous",
		Format( "Fixed Dec", 5, 0 ),
		Set Values(
			[95, 123, 74, 145, 64, 112, 107, 67, 81, 91, 142, 84, 85, 92, 112, 112, 115,
			116]
		)
	),
	New Column( "allthesame",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] )
	),
	New Column( "allcharthesame",
		Character,
		"Nominal",
		Set Selected,
		Set Values(
			{"zippy", "zippy", "zippy", "zippy", "zippy", "zippy", "zippy", "zippy",
			"zippy", "zippy", "zippy", "zippy", "zippy", "zippy", "zippy", "zippy",
			"zippy", "zippy"}
		)
	),
	Set Row States( [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ),
	Set Label Columns( :name )
);

colNamesList = dt &amp;lt;&amp;lt; get column names( String );
colsToDeleteList = {};
For( i = 1, i &amp;lt;= N Items( colNamesList ), i++,
	Summarize( dt, bygroup = by( colNamesList[i] ) );
	If( N Items( bygroup ) == 1 | (N Items( bygroup ) == 2 &amp;amp; bygroup[1] == ""),
		Insert Into( colsToDeleteList, colNamesList[i] )
	);
);
Show( colsToDeleteList );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Jul 2018 17:12:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-Delete-a-Column-Where-All-Rows-Have-The-Same-Value/m-p/62142#M33477</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-07-03T17:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select and Delete a Column Where All Rows Have The Same Value</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-Delete-a-Column-Where-All-Rows-Have-The-Same-Value/m-p/62144#M33479</link>
      <description>Thank you very much. Works like a champ.&lt;BR /&gt;Andy</description>
      <pubDate>Tue, 03 Jul 2018 17:30:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-Delete-a-Column-Where-All-Rows-Have-The-Same-Value/m-p/62144#M33479</guid>
      <dc:creator>Hegedus</dc:creator>
      <dc:date>2018-07-03T17:30:41Z</dc:date>
    </item>
  </channel>
</rss>

