<?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: Flagging an error if variable name does not match in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Flagging-an-error-if-variable-name-does-not-match/m-p/450266#M69701</link>
    <description>&lt;P&gt;&lt;EM&gt;The Contains Items() function requires the data to be in Associative Arrays.&amp;nbsp; If your items are in lists, the below method will work.&lt;/EM&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Inputdt = User Defined Data Table Name
mvdt = Existing Data Table Name;

//Get required variable lists from user define Data Table

varListInput = Column( Inputdt, "Variable Name" ) &amp;lt;&amp;lt; get values;

// Error trap - if # UserDefinedTable &amp;amp; # Existing Data Table variables don't match, then break code &amp;amp; output error message. 
//Obtain column names from existing Data Table from list
colnames = mvdt &amp;lt;&amp;lt; get column names( string );

show(colnames);
show(varListInput);

For( i = 1, i &amp;lt;= N Items( varListInput ), i++,
	If( !Contains( colnames, varListInput[i] ),
		Message = Dialog(
			"The Variable Name does not match with Existing Data Table.Please correct your Input Table."
		);
		Stop();
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Jan 2022 15:28:01 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-01-10T15:28:01Z</dc:date>
    <item>
      <title>Flagging an error if variable name does not match</title>
      <link>https://community.jmp.com/t5/Discussions/Flagging-an-error-if-variable-name-does-not-match/m-p/450187#M69699</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to build a simple error trap where it will flag the error if the variable name from the user defined variable name with the existing table variable name. For example as below;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;User defined Data table&lt;/P&gt;&lt;P&gt;Variable Name&lt;/P&gt;&lt;P&gt;1. Benzene&lt;/P&gt;&lt;P&gt;2. Methane&lt;/P&gt;&lt;P&gt;3. Ethane&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Existing Data Table&lt;/P&gt;&lt;P&gt;Variable Name&lt;/P&gt;&lt;P&gt;1. Benzene&lt;/P&gt;&lt;P&gt;2. Methane&lt;/P&gt;&lt;P&gt;3. Ethane&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. Propane&lt;/P&gt;&lt;P&gt;5. Pentane&lt;/P&gt;&lt;P&gt;6. Hexane&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to used !contains function, but it seemed that I dont use the syntax properly. I'm a very new to jmp script, so I'm seeking for anyone in the community help&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Inputdt = User Defined Data Table Name
mvdt = Existing Data Table Name

//Get required variable lists from user define Data Table

varListInput = Column( Inputdt, "Variable Name" ) &amp;lt;&amp;lt; get values;

// Error trap - if # UserDefinedTable &amp;amp; # Existing Data Table variables don't match, then break code &amp;amp; output error message. 
//Obtain column names from existing Data Table from list
colnames = mvdt &amp;lt;&amp;lt; get column names( string );

show(colnames);
show(varListInput);

If(!contains Item ("colnames", "varListInput"),
	Message = Dialog( "The Variable Name does not match with Existing Data Table.Please correct your Input Table." );
	Stop();
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:08:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Flagging-an-error-if-variable-name-does-not-match/m-p/450187#M69699</guid>
      <dc:creator>jacksonperry</dc:creator>
      <dc:date>2023-06-09T18:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging an error if variable name does not match</title>
      <link>https://community.jmp.com/t5/Discussions/Flagging-an-error-if-variable-name-does-not-match/m-p/450266#M69701</link>
      <description>&lt;P&gt;&lt;EM&gt;The Contains Items() function requires the data to be in Associative Arrays.&amp;nbsp; If your items are in lists, the below method will work.&lt;/EM&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Inputdt = User Defined Data Table Name
mvdt = Existing Data Table Name;

//Get required variable lists from user define Data Table

varListInput = Column( Inputdt, "Variable Name" ) &amp;lt;&amp;lt; get values;

// Error trap - if # UserDefinedTable &amp;amp; # Existing Data Table variables don't match, then break code &amp;amp; output error message. 
//Obtain column names from existing Data Table from list
colnames = mvdt &amp;lt;&amp;lt; get column names( string );

show(colnames);
show(varListInput);

For( i = 1, i &amp;lt;= N Items( varListInput ), i++,
	If( !Contains( colnames, varListInput[i] ),
		Message = Dialog(
			"The Variable Name does not match with Existing Data Table.Please correct your Input Table."
		);
		Stop();
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jan 2022 15:28:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Flagging-an-error-if-variable-name-does-not-match/m-p/450266#M69701</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-01-10T15:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging an error if variable name does not match</title>
      <link>https://community.jmp.com/t5/Discussions/Flagging-an-error-if-variable-name-does-not-match/m-p/450350#M69714</link>
      <description>&lt;P&gt;Thank you, it is working fine now :)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 01:11:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Flagging-an-error-if-variable-name-does-not-match/m-p/450350#M69714</guid>
      <dc:creator>jacksonperry</dc:creator>
      <dc:date>2022-01-11T01:11:24Z</dc:date>
    </item>
  </channel>
</rss>

