cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
AsymptoticCos
Level II

Split a Table without a Split by Column

I have a data table that looks like this, 

AsymptoticCos_0-1717003069041.png

I want to change it to something like this. 

AsymptoticCos_1-1717003108433.png

How do I do this in JSL? I don't have a reference column to split this against, but I know odd rows will be my first entry, and even rows will be my second entry always. 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Split a Table without a Split by Column

Create new column with the knowledge you have about odd and even rows and use that as your Split By column

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(8),
	Compress File When Saved(1),
	New Column("Column 1",
		Character,
		"Nominal",
		Set Values(
			{"Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1"}
		)
	),
	New Column("Column 2",
		Character,
		"Nominal",
		Set Values(
			{"Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1"}
		)
	),
	New Column("Column 3",
		Character,
		"Nominal",
		Set Values({"A", "1", "B", "2", "C", "3", "D", "4"})
	)
);

dt << New Column("By", Character, Nominal, Formula(
	If(Mod(Row(), 2),
		"Data 1";
	,
		"Data 2";
	);
));

dt_split = dt << Split(
	Split By(:By),
	Split(:Column 3),
	Output Table("Untitled 29.jmp"),
	Sort by Column Property
);
-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: Split a Table without a Split by Column

Create new column with the knowledge you have about odd and even rows and use that as your Split By column

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(8),
	Compress File When Saved(1),
	New Column("Column 1",
		Character,
		"Nominal",
		Set Values(
			{"Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1"}
		)
	),
	New Column("Column 2",
		Character,
		"Nominal",
		Set Values(
			{"Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1"}
		)
	),
	New Column("Column 3",
		Character,
		"Nominal",
		Set Values({"A", "1", "B", "2", "C", "3", "D", "4"})
	)
);

dt << New Column("By", Character, Nominal, Formula(
	If(Mod(Row(), 2),
		"Data 1";
	,
		"Data 2";
	);
));

dt_split = dt << Split(
	Split By(:By),
	Split(:Column 3),
	Output Table("Untitled 29.jmp"),
	Sort by Column Property
);
-Jarmo