cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
nguyendv0610
Level III

Checking loop through a table to check if the column is numeric or nominal

Capture.JPG

I have the following table that is the result from stacking and splitting a much larger table. As you can see, X1, 3 and 5 are Numeric and X2, 4 and 6 are Characters. Because this is a results of stacking and splitting, everything is converted to Nominal and Character, is there away to loop through all the columns, check if the value in the 1st row is numeric/continuous and convert the X1, X3 and X5 column back to numeric and continuous?

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Checking loop through a table to check if the column is numeric or nominal

Here is a simple script that will convert the columns found to have numeric values

Names Default To Here( 1 );
dt = Current Data Table();

colNames = dt << get column names( string, character );

For( i = 1, i <= N Items( colNames ), i++,
	If( Is Missing( Num( Column( dt, colNames[i] )[1] ) ) == 0,
		Column( dt, colNames[i] ) << data type( numeric ) << modeling type( continuous )
	)
);

It looks like you need to take the time to read through the Scripting Guide

     Help==>Books==>Scripting Guide

Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: Checking loop through a table to check if the column is numeric or nominal

Here is a simple script that will convert the columns found to have numeric values

Names Default To Here( 1 );
dt = Current Data Table();

colNames = dt << get column names( string, character );

For( i = 1, i <= N Items( colNames ), i++,
	If( Is Missing( Num( Column( dt, colNames[i] )[1] ) ) == 0,
		Column( dt, colNames[i] ) << data type( numeric ) << modeling type( continuous )
	)
);

It looks like you need to take the time to read through the Scripting Guide

     Help==>Books==>Scripting Guide

Jim