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

Newb Question - Basic Sequencing in a column

I'm a beginner in JMP and coding as a whole. I'm trying to figure out how I can make sequence of 0, 25, 50, 100, to repeat 8 times.

 

I tried Sequence(0,100,25,8) and obviously 75 shows up as well. 

 

And I cannot for the life of me figure it out. 

 

Chatgpt gave me the following code: 

 

If(Mod(Row(), 4) == 0,
	0,
	If(Mod(Row(), 4) == 1,
		25,
		If(Mod(Row(), 4) == 2,
			50,
			If(Mod(Row(), 4) == 3, 100, 0)
		)
	)
)

 

And it make absolutely no sense to me.

 

I would appreciate if there's an easier way, or to just dumb it down for me.

 

Thank you for your help!

 

3 REPLIES 3
jthi
Super User

Re: Newb Question - Basic Sequencing in a column

Easiest way to do this is to initialize new column with sequence data

jthi_1-1696791266536.png

you can then get the script from log if you have JMP16+ and enhanced log enabled (if you need it)

 

Local({dt},
	dt = Data Table("Untitled 2");
	dt << Begin Data Update << Add Rows(40);
	For Each Row(dt, :Column 1 = Sequence(0, 100, 25, 1));
	dt << End Data Update;
);

Edit: misread the question, you don't want to have 75 there. One option then is to select one 75, right click and select matching cells and delete those

jthi_0-1696791493322.png

(jmp is able to record this also)

-Jarmo
jthi
Super User

Re: Newb Question - Basic Sequencing in a column

ChatGPT answer is incorrect (JMP's indexing doesn't start from 0) and I would also write in different way in JMP anyway

If(Mod(Row() - 1, 4) == 0,
	0
, Mod(Row() - 1, 4) == 1,
	25
, Mod(Row() - 1, 4) == 2,
	50
, Mod(Row() - 1, 4) == 3,
	100
)

Using Match() is also most likely more clear in this case

Match(Mod(Row() - 1, 4), // JMP indexing starts from 1 instead of 0
	0, 0,
	1, 25,
	2, 50,
	3, 100,
	.
)

You can add either of these as a formula in a formula column and then add as many rows as you need.

 

Scripting Index is very helpful if you need to know what the functions do, it does also provide examples you can run. It can be found from JMP's Help menu

jthi_0-1696791887481.png

Help button will open JMP Help page for that function Modulo(number, divisor) 

-Jarmo
ErraticAttack
Level VI

Re: Newb Question - Basic Sequencing in a column

You can also just use Repat() and Set Values(), like this:

Names Default to Here( 1 );
nt = New Table( "test",
	<<New Column( "Sequence", "Numeric" ),
	<<Add Rows( 123 )
);

seq = Repeat( {0,25,50,100}, 100 );
seq = seq[1::N Rows( nt )];
nt:Sequence << Set Values( seq )
Jordan