<?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: date/colonne in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/date-colonne/m-p/636416#M83449</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Super, merci pour votre aide !&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 May 2023 11:15:09 GMT</pubDate>
    <dc:creator>hcarr01</dc:creator>
    <dc:date>2023-05-29T11:15:09Z</dc:date>
    <item>
      <title>date/colonne</title>
      <link>https://community.jmp.com/t5/Discussions/date-colonne/m-p/636384#M83444</link>
      <description>&lt;DIV&gt;Bonjour à tous,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;J’ai plusieurs colonnes :&lt;/DIV&gt;&lt;DIV&gt;1- Colonnes «&amp;nbsp;date début »&lt;/DIV&gt;&lt;DIV&gt;2- Colonnes « date fin »&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hcarr01_0-1685352112393.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/53187i556CA18A58E14B20/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hcarr01_0-1685352112393.png" alt="hcarr01_0-1685352112393.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Normalement, chaque colonne appartenant au groupe (2) devrait également appartenir au groupe (1) et vice versa. Nous devrions donc avoir le même nombre de colonnes dans les deux groupes.&lt;/DIV&gt;&lt;DIV&gt;Cependant, les colonnes appartenant au groupe 1 n’appartiennent pas au groupe 2 et vice versa.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;U&gt;Exemple&lt;/U&gt; :&lt;/SPAN&gt; « date début 9899 » mais la colonne « date fin 9899 » n’existe pas.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;L’objectif est d’avoir l’intersection de ces 2 groupes afin qu’il y ait les mêmes colonnes dans les 2 groupes.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&lt;EM&gt;&lt;FONT&gt;Je m’inspire du code suivant :&lt;/FONT&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

// build 
aa_duree = Associative Array();
aa_nonduree = Associative Array();

For Each({col_name}, dt &amp;lt;&amp;lt; Get Column Names("String"),
	If(Word(1, col_name) == "date début",
		aa_duree[Word(-1, col_name)] = col_name;
	, !IsMissing(Regex(col_name, "")),
		aa_nonduree[col_name] = 1;
	,
		continue()
	);
);
show(aa_duree);
show(aa_nonduree);

aa_duree_copy = aa_duree;
aa_duree_copy &amp;lt;&amp;lt; Intersect(aa_nonduree);
cols_to_keep = Insert(aa_duree_copy &amp;lt;&amp;lt; get keys, aa_duree_copy &amp;lt;&amp;lt; get values);

aa_duree_copy2 = aa_duree;
aa_nonduree_copy = aa_nonduree;
aa_duree_copy2 &amp;lt;&amp;lt; remove(aa_nonduree);
aa_nonduree_copy &amp;lt;&amp;lt; remove(aa_duree);
cols_to_remove = Insert(aa_nonduree_copy &amp;lt;&amp;lt; get keys, aa_duree_copy2 &amp;lt;&amp;lt; get values);

show(cols_to_keep, cols_to_remove);&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 29 May 2023 09:24:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/date-colonne/m-p/636384#M83444</guid>
      <dc:creator>hcarr01</dc:creator>
      <dc:date>2023-05-29T09:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: date/colonne</title>
      <link>https://community.jmp.com/t5/Discussions/date-colonne/m-p/636408#M83446</link>
      <description>&lt;P&gt;The example script you provided won't work because Word(1, col_name) will only return the first work of the string and you are comparing it to two words. So the if statement will always go to else-statement. There might be other issues, but that is at least one problem there. You can try changing Words for example to Starts With() &lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/character-functions-2.shtml?os=win&amp;amp;source=application#ww2489516" target="_blank"&gt;https://www.jmp.com/support/help/en/17.0/#page/jmp/character-functions-2.shtml?os=win&amp;amp;source=application#ww2489516&lt;/A&gt;. Also make sure the cases are correct when comparing strings&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 10:15:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/date-colonne/m-p/636408#M83446</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-05-29T10:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: date/colonne</title>
      <link>https://community.jmp.com/t5/Discussions/date-colonne/m-p/636411#M83447</link>
      <description>&lt;P&gt;Here is my old school way to attack the issue&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();

keep = {};
delete = {};

colNameList = dt &amp;lt;&amp;lt; get column names( string );
For Each( {col, i}, colNameList, colNameList[i] = Uppercase( col ) );

While( N Items( colNameList ) &amp;gt; 0,
	If(
		Contains( colNameList[1], Uppercase( "Date début" ) ),
			found = Contains( colNameList, Substitute( colNameList[1], Uppercase( "début" ), "FIN" ) );
			If( found &amp;gt; 0,
				Insert Into( keep, colNameList[1] );
				Insert Into( keep, colNameList[found] );
				Remove From( colNameList, found, 1 );
				Remove From( colNameList, 1, 1 );
			,
				Insert Into( delete, colNameList[1] );
				Remove From( colNameList, 1, 1 )
			);,
		Contains( colNameList[1], Uppercase( "Date fin" ) ),
			found = Contains( colNameList, Substitute( colNameList[1], "FIN", Uppercase( "début" ) ) );
			If( found &amp;gt; 0,
				Insert Into( keep, colNameList[1] );
				Insert Into( keep, colNameList[found] );
				Remove From( colNameList, found, 1 );
				Remove From( colNameList, 1, 1 );
			,
				Insert Into( delete, colNameList[1] );
				Remove From( colNameList, 1, 1 )
			);,
		Remove From( colNameList, 1, 1 )
	)
);

show( keep, delete );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 May 2023 10:52:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/date-colonne/m-p/636411#M83447</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-05-29T10:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: date/colonne</title>
      <link>https://community.jmp.com/t5/Discussions/date-colonne/m-p/636416#M83449</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Super, merci pour votre aide !&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 11:15:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/date-colonne/m-p/636416#M83449</guid>
      <dc:creator>hcarr01</dc:creator>
      <dc:date>2023-05-29T11:15:09Z</dc:date>
    </item>
  </channel>
</rss>

