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
AsymptoticCos
Level II

Create 1000 columns with similar formulas at one run

I have an input column (ColumnA) that essentially has the Index of the table. I want to add 1000 numeric columns to this table. Each of the columns will add the column number to the original column. 

 

Example: the first new column will have the formula, ColumnA+1. 

30th new column will have the formula, ColumnA+30. 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Create 1000 columns with similar formulas at one run

If you really need formulas and not just values, here is one option

Names Default To Here(1);

dt = New Table("test",
	Add Rows(2),
	New Column("ColumnA", Numeric, Continuous, Values([1, 2])),
	Invisible // open/create as invisible! (or make invisible)
);

For(i = 1, i <= 1000, i++,
	Eval(EvalExpr(
		dt << New Column("ColumnA+"||Char(i), Numeric, Continuous, Formula(
			:ColumnA + Expr(i)
		))
	));
);

dt << Show Window(1); // if you need table visible later

If speed is important using Invisible is one thing you can do.

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Create 1000 columns with similar formulas at one run

If you really need formulas and not just values, here is one option

Names Default To Here(1);

dt = New Table("test",
	Add Rows(2),
	New Column("ColumnA", Numeric, Continuous, Values([1, 2])),
	Invisible // open/create as invisible! (or make invisible)
);

For(i = 1, i <= 1000, i++,
	Eval(EvalExpr(
		dt << New Column("ColumnA+"||Char(i), Numeric, Continuous, Formula(
			:ColumnA + Expr(i)
		))
	));
);

dt << Show Window(1); // if you need table visible later

If speed is important using Invisible is one thing you can do.

-Jarmo
Byron_JMP
Staff

Re: Create 1000 columns with similar formulas at one run

1.  make 100 columns.

2. select all 100 columns

3. Cols>Standardize attibutes

4. Add a formula column property from the properties dropdown.

5. Edit the formula, put in your formula, and click OK in the formula editor

6. Finally click ok (top right of standardize attributes window)

 

but I'm not sure that's what you really want to do

 

JMP Systems Engineer, Health and Life Sciences (Pharma)