<?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 how to assign the same number of rows to each case based on years in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/how-to-assign-the-same-number-of-rows-to-each-case-based-on/m-p/577094#M78469</link>
    <description>&lt;P&gt;I have a vertical data set with uneven number of years' data (body weight, for example) for each case. Some have years 1,2,3,4,6 and some have 3,4,5. I want each case to have 6 rows with the year column containing 1,2,3,4,5,6 even though some of those years will not have a body weight. How can I assign each case 6 rows that recognize the appropriate missing year?&lt;/P&gt;</description>
    <pubDate>Sun, 04 Dec 2022 14:07:22 GMT</pubDate>
    <dc:creator>txwrangler</dc:creator>
    <dc:date>2022-12-04T14:07:22Z</dc:date>
    <item>
      <title>how to assign the same number of rows to each case based on years</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-assign-the-same-number-of-rows-to-each-case-based-on/m-p/577094#M78469</link>
      <description>&lt;P&gt;I have a vertical data set with uneven number of years' data (body weight, for example) for each case. Some have years 1,2,3,4,6 and some have 3,4,5. I want each case to have 6 rows with the year column containing 1,2,3,4,5,6 even though some of those years will not have a body weight. How can I assign each case 6 rows that recognize the appropriate missing year?&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2022 14:07:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-assign-the-same-number-of-rows-to-each-case-based-on/m-p/577094#M78469</guid>
      <dc:creator>txwrangler</dc:creator>
      <dc:date>2022-12-04T14:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign the same number of rows to each case based on years</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-assign-the-same-number-of-rows-to-each-case-based-on/m-p/577102#M78471</link>
      <description>&lt;P&gt;Assuming you have a good deal of data, a simple script can be used to add in the missing years.&amp;nbsp; Below is an example that creates an original table with some missing years, and then from that point performs a couple of steps that ends up with the missing years being added in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt = New Table( "Base",
	Add Rows( 10 ),
	New Column( "Case",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 1, 1, 1, 1, 2, 2, 2, 2, 2] ),
		Set Display Width( 43 )
	),
	New Column( "Year",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 2, 3, 5, 6, 1, 2, 4, 5, 6] )
	),
	New Column( "OtherStuff", formula(randomuniform()))
);

// Summarize original data table to get a data table of the cases
dtCase = dt &amp;lt;&amp;lt; Summary(
	Group( :Case ),
	Freq( "None" ),
	Weight( "None" ),
	output table name( "Cases" )
);
dtCase &amp;lt;&amp;lt; delete columns(:N Rows);

// Create a new table with just the years
dtYears = new table("years", new column("Year", values([1,2,3,4,5,6])));

// Perform a cartesian join to create a table with all combinations of cases and years
dtCY = Data Table( "Cases" ) &amp;lt;&amp;lt; Join(
	With( Data Table( "years" ) ),
	Cartesian Join,
	Output Table( "Case and Years" )
);

// Use a join on the original table to add in the misssing years
dt &amp;lt;&amp;lt; Join(
	With( dtCY ),
	Merge Same Name Columns,
	Match Flag( 0 ),
	By Matching Columns( :Case = :Case, :Year = :Year ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 0, 1 ),
	Preserve main table order( 1 ),
	Output Table( "Final" )
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Dec 2022 14:59:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-assign-the-same-number-of-rows-to-each-case-based-on/m-p/577102#M78471</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-12-04T14:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign the same number of rows to each case based on years</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-assign-the-same-number-of-rows-to-each-case-based-on/m-p/577130#M78472</link>
      <description>&lt;P&gt;This works! I had to assign to my original table to get the cases but the overall method works fine. Thanks much!&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2022 17:18:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-assign-the-same-number-of-rows-to-each-case-based-on/m-p/577130#M78472</guid>
      <dc:creator>txwrangler</dc:creator>
      <dc:date>2022-12-04T17:18:56Z</dc:date>
    </item>
  </channel>
</rss>

