<?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: using List as variable in an if-statement in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/using-List-as-variable-in-an-if-statement/m-p/531933#M75494</link>
    <description>&lt;P&gt;You need to use As Column() function, and restructure the name on the new column a bit&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = 
// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "$SAMPLE_DATA/big class.jmp" );

ColumnList = dt &amp;lt;&amp;lt; Get Column Names( String );
value = 60;
A = ColumnList[4];

If( Contains( A, "hei" ),
	var = As Column( A )[dt &amp;lt;&amp;lt; get rows where( As Column( a ) == value )]
);

dt &amp;lt;&amp;lt; New Column( "[" || A || "] at 45km/h");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2022 14:19:04 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-08-09T14:19:04Z</dc:date>
    <item>
      <title>using List as variable in an if-statement</title>
      <link>https://community.jmp.com/t5/Discussions/using-List-as-variable-in-an-if-statement/m-p/531892#M75491</link>
      <description>&lt;P&gt;I am trying to create a list with all column names and turning some of them into a variable.&lt;/P&gt;&lt;P&gt;That variable should be going into an if-statement but I am struggling with the "name unresolved" error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm guessing that JMP cannot find my previously defined variable but I do not know how to fix it even though I'm sure it should be quite simple.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
ColumnList = dt &amp;lt;&amp;lt; Get Column Names(String);

A = ColumnList[40];

If(Contains(A, "test"),
var = :A[dt &amp;lt;&amp;lt; get rows where( :column == value)];);&lt;BR /&gt;//&amp;nbsp;I&amp;nbsp;cannot&amp;nbsp;seem&amp;nbsp;to&amp;nbsp;get&amp;nbsp;it&amp;nbsp;to&amp;nbsp;take&amp;nbsp;the&amp;nbsp;column&amp;nbsp;saved&amp;nbsp;in&amp;nbsp;A&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would also like to know how I could potentially use the text of that variable in defining a column name.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column( "[A] at 45km/h");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:52:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/using-List-as-variable-in-an-if-statement/m-p/531892#M75491</guid>
      <dc:creator>Lien</dc:creator>
      <dc:date>2023-06-10T23:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: using List as variable in an if-statement</title>
      <link>https://community.jmp.com/t5/Discussions/using-List-as-variable-in-an-if-statement/m-p/531933#M75494</link>
      <description>&lt;P&gt;You need to use As Column() function, and restructure the name on the new column a bit&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = 
// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "$SAMPLE_DATA/big class.jmp" );

ColumnList = dt &amp;lt;&amp;lt; Get Column Names( String );
value = 60;
A = ColumnList[4];

If( Contains( A, "hei" ),
	var = As Column( A )[dt &amp;lt;&amp;lt; get rows where( As Column( a ) == value )]
);

dt &amp;lt;&amp;lt; New Column( "[" || A || "] at 45km/h");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 14:19:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/using-List-as-variable-in-an-if-statement/m-p/531933#M75494</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-08-09T14:19:04Z</dc:date>
    </item>
  </channel>
</rss>

