<?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 columns that contain specific string in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366132#M61580</link>
    <description>&lt;P&gt;Slight modification to eliminate the need for a extra list variable:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = New Table( "Example",
	Add Rows( 3 ),
	New Column( "A_Dummy", Character, "Nominal", Set Values( {"xx", "yy", "zz"} ) ),
	New Column( "B", Character, "Nominal", Set Values( {"a", "b", "c"} ) ),
	New Column( "C_Dummy", Character, "Nominal", Set Values( {"l", "m", "n"} ) )
);

cols = dt &amp;lt;&amp;lt; get column names( string );
For( i = N Items( cols ), i&amp;gt;=1, i--,
	If( Contains( cols[i], "Dummy" ),
		dt &amp;lt;&amp;lt; Delete Columns( i );
	)
);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Mar 2021 15:51:04 GMT</pubDate>
    <dc:creator>pauldeen</dc:creator>
    <dc:date>2021-03-08T15:51:04Z</dc:date>
    <item>
      <title>Select and delete columns that contain specific string</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366067#M61572</link>
      <description>&lt;P&gt;Hi jsl folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Can somebody comment on what's wrong with my coding below? I am trying to look for columns which contain a string called "Dummy" and trying to delete it but it is not working. Pls help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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 = New Table( "Example",
    Add Rows( 3 ),
    New Column( "A_Dummy", Character, "Nominal", Set Values( {"xx", "yy", "zz"} ) ),
    New Column( "B", Character, "Nominal", Set Values( {"a", "b", "c"} ) ),
    New Column( "C_Dummy", Character, "Nominal", Set Values( {"l", "m", "n"} ) )
);

cols = dt &amp;lt;&amp;lt; get column names( string );

If( Contains( cols, "Dummy" ), 
    dt &amp;lt;&amp;lt; Select Columns();
    dt &amp;lt;&amp;lt; Delete Columns();
);&lt;/CODE&gt;&lt;/PRE&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, 09 Jun 2023 22:07:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366067#M61572</guid>
      <dc:creator>brandon_mcrv</dc:creator>
      <dc:date>2023-06-09T22:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select and delete columns that contain specific string</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366074#M61573</link>
      <description>&lt;P&gt;Just to add on...The reason I am asking this is because I'd like to know if there's a bunch of column names like for example 50 columns which contains "_Dummy", how can I delete it switftly without having to name the specific column names by using known delete columns command like "dt &amp;lt;&amp;lt; delete column(column("A_Dummy"))". If I have to use this command, then I'd have to type 50 times all the unique column names.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 14:48:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366074#M61573</guid>
      <dc:creator>brandon_mcrv</dc:creator>
      <dc:date>2021-03-08T14:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select and delete columns that contain specific string</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366080#M61575</link>
      <description>&lt;P&gt;Contains will only give you first index of a match. You could either loop over the list to generate list with columns to delete or delete while you loop:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = New Table( "Example",
Add Rows( 3 ),
New Column( "A_Dummy", Character, "Nominal", Set Values( {"xx", "yy", "zz"} ) ),
New Column( "B", Character, "Nominal", Set Values( {"a", "b", "c"} ) ),
New Column( "C_Dummy", Character, "Nominal", Set Values( {"l", "m", "n"} ) ));&lt;BR /&gt;
cols = dt &amp;lt;&amp;lt; get column names( string );

for(i = 1, i &amp;lt;= N Items(cols), i++,
	If(Contains(cols[i],"Dummy"),
		dt &amp;lt;&amp;lt; Delete Columns(cols[i])
	);	
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Mar 2021 14:50:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366080#M61575</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-03-08T14:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select and delete columns that contain specific string</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366098#M61576</link>
      <description>&lt;P&gt;This is a modified version that may work for you and that is easy to understand.&lt;/P&gt;&lt;P&gt;You would need a loop over the columns to see, where the character string is in,&lt;/P&gt;&lt;P&gt;and your usage of select and delete was not right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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 = New Table( "Example",
	Add Rows( 3 ),
	New Column( "A_Dummy", Character, "Nominal", Set Values( {"xx", "yy", "zz"} ) ),
	New Column( "B", Character, "Nominal", Set Values( {"a", "b", "c"} ) ),
	New Column( "C_Dummy", Character, "Nominal", Set Values( {"l", "m", "n"} ) )
);

cols = dt &amp;lt;&amp;lt; get column names( string );

delete_lst = {};

For( i = 1, i &amp;lt;= N Items( cols ), i++,
	If( Contains( cols[i], "Dummy" ),
		Insert Into( delete_lst, cols[i] )
	)
);

dt &amp;lt;&amp;lt; Delete Columns( delete_lst );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Mar 2021 15:00:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366098#M61576</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2021-03-08T15:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Select and delete columns that contain specific string</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366132#M61580</link>
      <description>&lt;P&gt;Slight modification to eliminate the need for a extra list variable:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = New Table( "Example",
	Add Rows( 3 ),
	New Column( "A_Dummy", Character, "Nominal", Set Values( {"xx", "yy", "zz"} ) ),
	New Column( "B", Character, "Nominal", Set Values( {"a", "b", "c"} ) ),
	New Column( "C_Dummy", Character, "Nominal", Set Values( {"l", "m", "n"} ) )
);

cols = dt &amp;lt;&amp;lt; get column names( string );
For( i = N Items( cols ), i&amp;gt;=1, i--,
	If( Contains( cols[i], "Dummy" ),
		dt &amp;lt;&amp;lt; Delete Columns( i );
	)
);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Mar 2021 15:51:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366132#M61580</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2021-03-08T15:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Select and delete columns that contain specific string</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366976#M61685</link>
      <description>Hi jthi, thanks for trying to help. I found that the script actually deletes all the columns regardless of having the "Dummy" string or not. Anyway, Georg and pauldeen already provided the solution.</description>
      <pubDate>Thu, 11 Mar 2021 02:06:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366976#M61685</guid>
      <dc:creator>brandon_mcrv</dc:creator>
      <dc:date>2021-03-11T02:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select and delete columns that contain specific string</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366977#M61686</link>
      <description>Excellent, it works perfectly ! Thanks !</description>
      <pubDate>Thu, 11 Mar 2021 02:07:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366977#M61686</guid>
      <dc:creator>brandon_mcrv</dc:creator>
      <dc:date>2021-03-11T02:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Select and delete columns that contain specific string</title>
      <link>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366978#M61687</link>
      <description>It works ! Thanks for the solution, Georg !</description>
      <pubDate>Thu, 11 Mar 2021 02:08:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-and-delete-columns-that-contain-specific-string/m-p/366978#M61687</guid>
      <dc:creator>brandon_mcrv</dc:creator>
      <dc:date>2021-03-11T02:08:03Z</dc:date>
    </item>
  </channel>
</rss>

