<?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: Summarize Function with multiple by columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Summarize-Function-with-multiple-by-columns/m-p/189151#M40788</link>
    <description>&lt;P&gt;There's not quite enough information in your post to be sure I know what the problem is. It would be helpful to know what VarList is, and what the result of the &amp;lt;&amp;lt;Get Selected() message is. However, I suspect that VarList is a list of columns, liket this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=open("$SAMPLE_DATA\Big Class.jmp");
varname={:age, :sex};&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If so, then you need to put use Eval() around varname in the Summarize() function, like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

varname = {:age, :sex};

//varName = VarList &amp;lt;&amp;lt;Get selected();
numCols = N Items( varName );
n = N Row( dt );

If(
	numCols == 0, 
	//do one thing
,
	numCols &amp;gt; 0,
		Summarize( dt, cat = by( Eval( varname ) ), c = count );
	//do other things
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 25 Mar 2019 21:30:38 GMT</pubDate>
    <dc:creator>Jeff_Perkinson</dc:creator>
    <dc:date>2019-03-25T21:30:38Z</dc:date>
    <item>
      <title>Summarize Function with multiple by columns</title>
      <link>https://community.jmp.com/t5/Discussions/Summarize-Function-with-multiple-by-columns/m-p/189142#M40787</link>
      <description>&lt;P&gt;All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to write a script that gets a count of observations, potentially&amp;nbsp;by 1 or more columns (as determined by input from the user). I can get the script to work for one column, but not for two or more. How do I adjust the code in the by step of the summarize function to handle 1+ columns?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a sample of script:&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;varName = VarList &amp;lt;&amp;lt;Get selected();
numCols = nitems(varName);
n = nrow(dt);

if(numCols == 0,
	//do one thing
,numCols&amp;gt;0,
	summarize(dt, cat = by(Column(dt,varName)),c=count);
	//do other things
);
	&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;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Sarah&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 21:08:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summarize-Function-with-multiple-by-columns/m-p/189142#M40787</guid>
      <dc:creator>seburke89</dc:creator>
      <dc:date>2019-03-25T21:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize Function with multiple by columns</title>
      <link>https://community.jmp.com/t5/Discussions/Summarize-Function-with-multiple-by-columns/m-p/189151#M40788</link>
      <description>&lt;P&gt;There's not quite enough information in your post to be sure I know what the problem is. It would be helpful to know what VarList is, and what the result of the &amp;lt;&amp;lt;Get Selected() message is. However, I suspect that VarList is a list of columns, liket this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=open("$SAMPLE_DATA\Big Class.jmp");
varname={:age, :sex};&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If so, then you need to put use Eval() around varname in the Summarize() function, like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

varname = {:age, :sex};

//varName = VarList &amp;lt;&amp;lt;Get selected();
numCols = N Items( varName );
n = N Row( dt );

If(
	numCols == 0, 
	//do one thing
,
	numCols &amp;gt; 0,
		Summarize( dt, cat = by( Eval( varname ) ), c = count );
	//do other things
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Mar 2019 21:30:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summarize-Function-with-multiple-by-columns/m-p/189151#M40788</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2019-03-25T21:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize Function with multiple by columns</title>
      <link>https://community.jmp.com/t5/Discussions/Summarize-Function-with-multiple-by-columns/m-p/189745#M40839</link>
      <description>&lt;P&gt;Sorry for the confusion on the varname variable. You've got it right - it's a list of column names that depend on input from the user from a GUI (that's the varList -&amp;nbsp;a column list box). And&amp;nbsp;you've solved my problem. Love it when it's a simple fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For my future knowledge then, anytime I want to reference data table column names in a function in JSL, things should work well with the eval() command around it? I always seem to have problems with that - especially when coding graphs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks much!&lt;/P&gt;&lt;P&gt;Sarah&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 16:28:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summarize-Function-with-multiple-by-columns/m-p/189745#M40839</guid>
      <dc:creator>seburke89</dc:creator>
      <dc:date>2019-03-27T16:28:30Z</dc:date>
    </item>
  </channel>
</rss>

