<?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 do i extract the number of levels from a distribution in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-i-extract-the-number-of-levels-from-a-distribution/m-p/795064#M97166</link>
    <description>&lt;P&gt;Here is an example of one way to do this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

summarize( dt, levels = By( :Age ) );

dtNew = New Table( "Count", 
	Add Rows( 1 ),
	New Column( "Count" )
);

dtNew:Count[1] = N Items( Levels );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is a second example that reads the Frequencies table directly and count the number of rows&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

// Report snapshot: Big Class - Distribution of sex
dis = Data Table( "Big Class" ) &amp;lt;&amp;lt; Distribution( Nominal Distribution( Column( :age ) ) );

dtNew = New Table( "Count2", 
	Add Rows( 1 ),
	New Column( "Count" )
);

// Calculate the number of items in the Frequencies table, minus the 
// the last row which is the Totals row
tableLevels = N Items( report(dis)["Frequencies",StringColBox(1)] &amp;lt;&amp;lt; get ) - 1;
dtNew:Count[1] = tableLevels;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Sep 2024 10:58:09 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2024-09-04T10:58:09Z</dc:date>
    <item>
      <title>How do i extract the number of levels from a distribution</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-i-extract-the-number-of-levels-from-a-distribution/m-p/794925#M97158</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I would like to get a JMP Script that allows me to extract the value that i highlighted in the red box and to put it into a column of a new table. PS: I know that it is possible to generate a table from the distribution with the command Make into Data Table but this command does not work on the number in the box.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-09-04 095200.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67881i46F0EB2ACEA66A5F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2024-09-04 095200.png" alt="Screenshot 2024-09-04 095200.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 07:55:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-i-extract-the-number-of-levels-from-a-distribution/m-p/794925#M97158</guid>
      <dc:creator>ConstructHorse2</dc:creator>
      <dc:date>2024-09-04T07:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract the number of levels from a distribution</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-i-extract-the-number-of-levels-from-a-distribution/m-p/795064#M97166</link>
      <description>&lt;P&gt;Here is an example of one way to do this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

summarize( dt, levels = By( :Age ) );

dtNew = New Table( "Count", 
	Add Rows( 1 ),
	New Column( "Count" )
);

dtNew:Count[1] = N Items( Levels );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is a second example that reads the Frequencies table directly and count the number of rows&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

// Report snapshot: Big Class - Distribution of sex
dis = Data Table( "Big Class" ) &amp;lt;&amp;lt; Distribution( Nominal Distribution( Column( :age ) ) );

dtNew = New Table( "Count2", 
	Add Rows( 1 ),
	New Column( "Count" )
);

// Calculate the number of items in the Frequencies table, minus the 
// the last row which is the Totals row
tableLevels = N Items( report(dis)["Frequencies",StringColBox(1)] &amp;lt;&amp;lt; get ) - 1;
dtNew:Count[1] = tableLevels;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 10:58:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-i-extract-the-number-of-levels-from-a-distribution/m-p/795064#M97166</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-09-04T10:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do i extract the number of levels from a distribution</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-i-extract-the-number-of-levels-from-a-distribution/m-p/797086#M97288</link>
      <description>&lt;P&gt;After my question I managed to write the code with method two on my own but method one seems more convenient and immediate. Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 06:33:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-i-extract-the-number-of-levels-from-a-distribution/m-p/797086#M97288</guid>
      <dc:creator>ConstructHorse2</dc:creator>
      <dc:date>2024-09-09T06:33:29Z</dc:date>
    </item>
  </channel>
</rss>

