cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
AGB
AGB
Level I

Recode using if and count functions

Hi,

 

I am relatively new to JMP and I am struggling to combine different functions using recoding functions and I would appreciate your help.

 

I have a date table with one column containing plate numbers. Each Plate ID has a repetitive set of Names T0X, T0Y and T0Z associated. Now I want to recode X, Y and Z into numbers, starting from X =1, Y = 2 and Z = 3, and going on in steps of three (X = 4, Y = 5, Z = 6....).

Any help would be greatly appreciated.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Recode using if and count functions

Maybe this could work as starting point?

 

Names Default To Here(1);

dt = New Table("Test_Recode",
	Add Rows(9),
	Compress File When Saved(1),
	New Column("Plate",
		Numeric,
		"Continuous",
		Format("Best", 15),
		Set Values([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]),
		Set Display Width(48)
	),
	New Column("Name",
		Character(3),
		"Nominal",
		Set Values({"T0X", "T0Y", "T0Z", "T0X", "T0Y", "T0Z", "T0X", "T0Y", "T0Z", "T0X", "T0Y", "T0Z"}),
		Set Display Width(48)
	),
	New Column("Recode Output",
		Character(3),
		"Nominal",
		Set Values({"T01", "T02", "T03", "T04", "T05", "T06", "T07", "T08", "T09"}),
		Set Display Width(95)
	)
);
dt << new column("test", Character, << Formula(
"T" || 
If((:Plate-1)*3 < 9, "0", "") || 
Char(Match(Right(:Name, 1),
	"X", 1,
	"Y", 2,
	"Z", 3
) + (:Plate-1)*3)));

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Recode using if and count functions

Maybe this could work as starting point?

 

Names Default To Here(1);

dt = New Table("Test_Recode",
	Add Rows(9),
	Compress File When Saved(1),
	New Column("Plate",
		Numeric,
		"Continuous",
		Format("Best", 15),
		Set Values([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]),
		Set Display Width(48)
	),
	New Column("Name",
		Character(3),
		"Nominal",
		Set Values({"T0X", "T0Y", "T0Z", "T0X", "T0Y", "T0Z", "T0X", "T0Y", "T0Z", "T0X", "T0Y", "T0Z"}),
		Set Display Width(48)
	),
	New Column("Recode Output",
		Character(3),
		"Nominal",
		Set Values({"T01", "T02", "T03", "T04", "T05", "T06", "T07", "T08", "T09"}),
		Set Display Width(95)
	)
);
dt << new column("test", Character, << Formula(
"T" || 
If((:Plate-1)*3 < 9, "0", "") || 
Char(Match(Right(:Name, 1),
	"X", 1,
	"Y", 2,
	"Z", 3
) + (:Plate-1)*3)));

-Jarmo
AGB
AGB
Level I

Re: Recode using if and count functions

This is awesome, thanks for the fast response!