<?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: How to replace :column_name with variable in JMP JSL? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-replace-column-name-with-variable-in-JMP-JSL/m-p/732545#M91436</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
hvar = "height";
gvar = "sex";

std = Col Std Dev( if(!Excluded( Row State() ) &amp;amp; as column(dt, gvar) == "M", as column(dt, hvar) ));

//std = Col Std Dev( if(Excluded( Row State() ) == 0 &amp;amp; :sex =="M", column(hvar) ));
show(std);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sometimes you need to use "as column".&amp;nbsp; Sometimes just "column".&lt;/P&gt;</description>
    <pubDate>Mon, 11 Mar 2024 19:18:18 GMT</pubDate>
    <dc:creator>pmroz</dc:creator>
    <dc:date>2024-03-11T19:18:18Z</dc:date>
    <item>
      <title>How to replace :column_name with variable in JMP JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-replace-column-name-with-variable-in-JMP-JSL/m-p/732535#M91435</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;Can you help me to fix the code error below? How to use variable to replace :column name in the correct way? Thank you so much for your help.&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 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
hvar = "height";
gvar = "sex";

std = Col Std Dev( if(Excluded( Row State() ) == 0 &amp;amp; column(gvar) =="M", column(hvar) ));

//std = Col Std Dev( if(Excluded( Row State() ) == 0 &amp;amp; :sex =="M", column(hvar) ));
show(std);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Mar 2024 19:09:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-replace-column-name-with-variable-in-JMP-JSL/m-p/732535#M91435</guid>
      <dc:creator>lazzybug</dc:creator>
      <dc:date>2024-03-11T19:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace :column_name with variable in JMP JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-replace-column-name-with-variable-in-JMP-JSL/m-p/732545#M91436</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
hvar = "height";
gvar = "sex";

std = Col Std Dev( if(!Excluded( Row State() ) &amp;amp; as column(dt, gvar) == "M", as column(dt, hvar) ));

//std = Col Std Dev( if(Excluded( Row State() ) == 0 &amp;amp; :sex =="M", column(hvar) ));
show(std);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sometimes you need to use "as column".&amp;nbsp; Sometimes just "column".&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2024 19:18:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-replace-column-name-with-variable-in-JMP-JSL/m-p/732545#M91436</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2024-03-11T19:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace :column_name with variable in JMP JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-replace-column-name-with-variable-in-JMP-JSL/m-p/733143#M91450</link>
      <description>&lt;P&gt;How you replace it depends on the use case, in your case using AsColumn as&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4550"&gt;@pmroz&lt;/a&gt;&amp;nbsp;suggested is the easiest option.&lt;/P&gt;
&lt;P&gt;Few links&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;LI-MESSAGE title="Column() vs As Column() vs datable:column vs dt:As name(&amp;amp;quot;column&amp;amp;quot;)" uid="542062" url="https://community.jmp.com/t5/Discussions/Column-vs-As-Column-vs-datable-column-vs-dt-As-name-quot-column/m-p/542062#U542062" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;LI-MESSAGE title="Referencing a Column in JSL" uid="395844" url="https://community.jmp.com/t5/Discussions/Referencing-a-Column-in-JSL/m-p/395844#U395844" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://www.jmp.com/support/help/en/17.2/#page/jmp/programming-functions.shtml?os=win&amp;amp;source=application#ww5006506" target="_self"&gt;JSL Syntax Reference - As Column&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://www.jmp.com/support/help/en/17.2/#page/jmp/row-functions-2.shtml?os=win&amp;amp;source=application#ww4974567" target="_blank" rel="noopener"&gt;JSL Syntax Reference - Column()&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Below are few other options but they do require more scripting which is usually unnecessary in this type of cases&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 = Open("$SAMPLE_DATA/Big Class.jmp");

hvar = "height";
gvar = "sex";

// As Column
std = Col Std Dev(If(!Excluded(Row State()) &amp;amp; As Column(dt, gvar) == "M", As Column(dt, hvar)));

// Data table subscripting
// https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013
rows_of_interest = dt &amp;lt;&amp;lt; Get Rows Where(Excluded(Row State()) == 0 &amp;amp; Column(gvar)[] == "M");
std2 = Std Dev(dt[rows_of_interest, hvar]);

// Build and evaluate expression
// https://community.jmp.com/t5/JSL-Cookbook-Archived/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/ta-p/48998
std3 = Eval(Substitute(
	Expr(Col Std Dev(If(!Excluded(Row State()) &amp;amp; groupcol == "M", numcol))),
	Expr(groupcol), Name Expr(AsColumn(gvar)),
	Expr(numcol), Name Expr(AsColumn(hvar))
));

// Check
std4 = Col Std Dev(If(Excluded(Row State()) == 0 &amp;amp; :sex == "M", :height));

show(std, std2, std3, std4);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2024 06:05:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-replace-column-name-with-variable-in-JMP-JSL/m-p/733143#M91450</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-03-12T06:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace :column_name with variable in JMP JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-replace-column-name-with-variable-in-JMP-JSL/m-p/733359#M91475</link>
      <description>&lt;P&gt;Thank you so much. This works very well.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2024 15:53:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-replace-column-name-with-variable-in-JMP-JSL/m-p/733359#M91475</guid>
      <dc:creator>lazzybug</dc:creator>
      <dc:date>2024-03-12T15:53:04Z</dc:date>
    </item>
  </channel>
</rss>

