cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Stokes
Level IV

How to select column from 1 to n

I am trying to select transpose column by the column number,

Considering there are too many column, is there a way to select from column(1) to column(n)

I am currently using below method which won't work when n>9999.

Thanks

 

Transpose(
columns(
Column( 3 ),
Column( 4 ),
.............
Column( 9999 ))

2 REPLIES 2
jthi
Super User

Re: How to select column from 1 to n

First create list of strings with column names (many ways to do this, in the example I use transform Each and index) and then use Eval in Columns().

 

Something like this:

Names Default To Here(1);

//setup example data
dt = Open("$SAMPLE_DATA/Blood Pressure.jmp");
Column(3) << Set Name("1");
Column(4) << Set Name("2");
Column(5) << Set Name("3");
Column(6) << Set Name("4");
Column(7) << Set Name("5");

col_list = Transform Each({num}, AsList(Index(1, 5)`), Char(num)); //JMP16
dt << Transpose(
	columns(Eval(col_list)),
	By(:Dose),
	Label(:Subject)
);
-Jarmo
txnelson
Super User

Re: How to select column from 1 to n

Here is my take on the issue, where you can just specift which column numbers you want to transform

Names Default To Here( 1 );

//setup example data
dt = Open( "$SAMPLE_DATA/Blood Pressure.jmp" );

// add a complex col name to insure script can handle them
dt:bp 8m << set name( "BP+8M" );

// make table large
For( i = 1, i <= 11000, i++,
	dt << New Column( Column( dt, Mod( i, 9 ) + 3 ) << get name,
		set each value( As Column( dt, Mod( i, 9 ) + 3 ) )
	)
);
// get rid of first 2 non useful columns
dt << delete columns( 1, 2 );

// get list of col names
colList = dt << get column names();

//set column numbers to be used
startColNum = 5;
endColNum = 10100;

// transform columns
transList = {};
For( i = startColNum , i <= endColNum, i++,
	Insert Into( transList, colList[i] )
);
dt << Transpose( columns( transList ) );
Jim

Recommended Articles