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
Dipesh
Level I

JMP script question: how to divide one column by another

Dear all, 

 

I am a regular user of JMP but new to Script. I am exporting data from a manufacturing system (SAP) and I would like to convert the kilogram figures that it outputs into %m figures. I am able to do this manually, however it is very time consuming so would like to write a script to do this. 

 

The user will need to input the following at the begining for the script to work: 

- Select which columns are required to convert into %m 

- Select which column (for each row) represents the total mass figure 

 

e.g. if we have a + b + c = d 

a, b and c will need to convert to %m and d will be the total mass figure 

Example attached 

 

For the new column name, I would like the user to write this. 

 

If anyone can directly help, or point me in the right direction to do this I would be very appreciative. 

 

Regards,

 

Dipesh 

1 ACCEPTED SOLUTION

Accepted Solutions
msharp
Super User (Alumni)

Re: JMP script question: how to divide one column by another

As a new scripter the best thing you can do is struggle through a small project like this.  You are also asking for quite a bit in this post, so wasn't sure which question to answer.  I decided to just help you get started, so I've provided the small script below that should get you going in the right direction.  It has a small user interface and takes the information and adds a new column.  Hope it helps!

 

Names Default to Here(1);
dt = current data table();
colNames = dt << Get Column Names(String);

NW = New Window("Convert to m%",
	vlistbox(
		text box("Pick a column!"),
		cb = combo box(colNames),
		text box("Pick another column!"),
		cb2 = combo box(colNames),
		ok = button box("OK", 
			col = cb << Get Selected;
			col2 = cb2 << Get Selected;
			run();
		)
	)
);

run = function({},
	col1 = Column(dt, col);
	col2 = Column(dt, col2);
	dt << New Column("m% for " || col, Numeric, Continuous, Formula(col1[] - col2[]));
);

View solution in original post

1 REPLY 1
msharp
Super User (Alumni)

Re: JMP script question: how to divide one column by another

As a new scripter the best thing you can do is struggle through a small project like this.  You are also asking for quite a bit in this post, so wasn't sure which question to answer.  I decided to just help you get started, so I've provided the small script below that should get you going in the right direction.  It has a small user interface and takes the information and adds a new column.  Hope it helps!

 

Names Default to Here(1);
dt = current data table();
colNames = dt << Get Column Names(String);

NW = New Window("Convert to m%",
	vlistbox(
		text box("Pick a column!"),
		cb = combo box(colNames),
		text box("Pick another column!"),
		cb2 = combo box(colNames),
		ok = button box("OK", 
			col = cb << Get Selected;
			col2 = cb2 << Get Selected;
			run();
		)
	)
);

run = function({},
	col1 = Column(dt, col);
	col2 = Column(dt, col2);
	dt << New Column("m% for " || col, Numeric, Continuous, Formula(col1[] - col2[]));
);