cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Mickyboy
Level V

Wild card for Match function

Hi Everyone,

I had a variable "medium" and l needed a grouping variable so i created another variable for the grouping "EMEM Medium" and below if the code i used to populate the new variable.

Match( :Medium,
	"Standard", "Standard",
	"Standard 1", "Standard",
	"Standard 2", "Standard",
	"Standard 3", "Standard",
	"Standard 4", "Standard",
	"Standard 5", "Standard",
	"Standard 6", "Standard",
	"Sigma", "Sigma",
	"Sigma 1", "Sigma",
	"Sigma 2", "Sigma",
	"Sigma 3", "Sigma",
	"Sigma 4", "Sigma",
	"Sigma 5", "Sigma",
	"Sigma 6", "Sigma",
         "else", -9999)

just wondering if there is wildcard l could have used, or a different approach, to make the syntax a little more compact and readable.

 

Thanks

Mick

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Georg
Level VII

Re: Wild card for Match function

I think it's not possible with match, see:

Match (jmp.com)

 

But you can uses word in this case, it's much simpler:

 

Names Default To Here( 1 );

dt = New Table( "test",
	New Column( "Medium","Character",
		set values(
			{"Standard", "Standard 1", "Standard 2", "Standard 3", "Standard 4", "Standard 5", "Standard 6", "Sigma", "Sigma 1", "Sigma 2", "Sigma 3",
			"Sigma 4", "Sigma 5", "Sigma 6"}
		)
	)
);

dt << New Column( "Match", "Character",
	formula(
		Match( :Medium,
			"Standard", "Standard",
			"Standard 1", "Standard",
			"Standard 2", "Standard",
			"Standard 3", "Standard",
			"Standard 4", "Standard",
			"Standard 5", "Standard",
			"Standard 6", "Standard",
			"Sigma", "Sigma",
			"Sigma 1", "Sigma",
			"Sigma 2", "Sigma",
			"Sigma 3", "Sigma",
			"Sigma 4", "Sigma",
			"Sigma 5", "Sigma",
			"Sigma 6", "Sigma",
			"else", -9999
		)
	)
);

dt << New Column( "Word", "Character",
	formula(
word(1, :Medium)
	)
);
Georg

View solution in original post

3 REPLIES 3
Georg
Level VII

Re: Wild card for Match function

I think it's not possible with match, see:

Match (jmp.com)

 

But you can uses word in this case, it's much simpler:

 

Names Default To Here( 1 );

dt = New Table( "test",
	New Column( "Medium","Character",
		set values(
			{"Standard", "Standard 1", "Standard 2", "Standard 3", "Standard 4", "Standard 5", "Standard 6", "Sigma", "Sigma 1", "Sigma 2", "Sigma 3",
			"Sigma 4", "Sigma 5", "Sigma 6"}
		)
	)
);

dt << New Column( "Match", "Character",
	formula(
		Match( :Medium,
			"Standard", "Standard",
			"Standard 1", "Standard",
			"Standard 2", "Standard",
			"Standard 3", "Standard",
			"Standard 4", "Standard",
			"Standard 5", "Standard",
			"Standard 6", "Standard",
			"Sigma", "Sigma",
			"Sigma 1", "Sigma",
			"Sigma 2", "Sigma",
			"Sigma 3", "Sigma",
			"Sigma 4", "Sigma",
			"Sigma 5", "Sigma",
			"Sigma 6", "Sigma",
			"else", -9999
		)
	)
);

dt << New Column( "Word", "Character",
	formula(
word(1, :Medium)
	)
);
Georg
jthi
Super User

Re: Wild card for Match function

JMP can also create the Word column shown by @Georg interactively (might need some additional handling for non-matches).

Right click on column header and create new formula column:

jthi_0-1657186300878.png

or use recode:

jthi_1-1657186337862.png

jthi_2-1657186343318.png

 

 

-Jarmo
Mickyboy
Level V

Re: Wild card for Match function

Brilliant, thank you Georg, also thank you to jthi, appreciate the replies, thank you both