cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar
Ken_K
Level I

"Name Selection in Column" function in JSL

is there JSL equivalent of menu function

Rows=> Row Selection => Name Selection In Column?

 

let's say there's column A and I used select where to select rows in Column A.   How to create Column B with value 1 for selected rows and 0 for not selected?

2 REPLIES 2
jthi
Super User

Re: "Name Selection in Column" function in JSL

<< Name Selection In Column() is a message you can send to data table. This seems to only support strings for values though, so if you need numbers you have to use some other method

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Select Where(:Age < 14);
dt << Name Selection in Column(
	Column Name("Younger"),
	Selected("Yes"),
	Unselected("No")
);

jthi_0-1715703299538.png

Here is other method if you wish to use numbers (similar idea could be used for other values, but you have to initialize empty list using Repeat() instead of J())

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Select Where(:Age < 14);

selrows = dt << Get Selected Rows;
vals = J(1, N Rows(dt), 0);
vals[selrows] = 1;

dt << New Column("Selection", Numeric, Nominal, Values(vals));

 

-Jarmo
mikedriscoll
Level VI

Re: "Name Selection in Column" function in JSL

Regarding the part about that jsl command only supporting strings, I just tried it with a 0 / 1 (removed quotes), and it worked ok. Resulted in a nominal numeric column. So, at least on JMP 17.2, it works. Though as you say, may not be always supported.