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
powerpuff
Level IV

Min and Max values of all numeric columns

I am trying to extract minimum and maximum values from all numeric columns of a table. However, I also want the column name of which the values are extracted. 

Here is my script:

dt = Open("Path");
nc = N Row(dt);
mycol = dt << get column names;
//show(mycol);
for(i=1,i<=nc,i++,
If( x = Column( dt, i ) << get data type() == "Numeric",
myMax = col max(column(dt,i));
print("Max:",myMax);
myMin = col min(column(dt,i));
print("Min",myMin);
));

I also get the following JMP Alert when I run this script: 

Check script for using an assignment with single = where a test for equality with double == is normally expected. Expression is
"x = Column( dt, i ) << get data type() == "Numeric""

However, I am able to extract the min and max values. Can anyone point out as to how I can extract the names of those numeric columns as well and put that in a new table with Column Name, Min and Max values? Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Min and Max values of all numeric columns

Try this one

Names Default To Here( 1 );
dt = Open( "path" );

For( i = 1, i <= N Col( dt ), i++,
	If( Column( dt, i ) << get data type == "Numeric",
		Write( "\!n", Column( dt, i ) << get name );
		Write( Column( dt, i ), "\!nMin: ", Col Min( Column( dt, i ) ) );
		Write( "\!nMax: ", Col Max( Column( dt, i ) ) );
	)
);
Jim

View solution in original post

uday_guntupalli
Level VIII

Re: Min and Max values of all numeric columns

@powerpuff,

 

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

NumericCols = {};
Minimums = {};
Maximums = {}; 

for(i = 1, i <= N Cols(dt), i++,
		Col = Column(dt,i);
		ColDataType = Col << Get Data Type; 
		If( ColDataType == "Numeric",
			Insert Into(NumericCols,Col << Get Name); 
			Insert Into(Minimums, Col Min(Col)); 
			Insert Into(Maximums, Col Max(Col)); 
		  );
   );
   
Show(NumericCols); 
Show(Minimums); 
Show(Maximums); 
Best
Uday

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Min and Max values of all numeric columns

Try this one

Names Default To Here( 1 );
dt = Open( "path" );

For( i = 1, i <= N Col( dt ), i++,
	If( Column( dt, i ) << get data type == "Numeric",
		Write( "\!n", Column( dt, i ) << get name );
		Write( Column( dt, i ), "\!nMin: ", Col Min( Column( dt, i ) ) );
		Write( "\!nMax: ", Col Max( Column( dt, i ) ) );
	)
);
Jim
uday_guntupalli
Level VIII

Re: Min and Max values of all numeric columns

@powerpuff,

 

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

NumericCols = {};
Minimums = {};
Maximums = {}; 

for(i = 1, i <= N Cols(dt), i++,
		Col = Column(dt,i);
		ColDataType = Col << Get Data Type; 
		If( ColDataType == "Numeric",
			Insert Into(NumericCols,Col << Get Name); 
			Insert Into(Minimums, Col Min(Col)); 
			Insert Into(Maximums, Col Max(Col)); 
		  );
   );
   
Show(NumericCols); 
Show(Minimums); 
Show(Maximums); 
Best
Uday
KarenC
Super User (Alumni)

Re: Min and Max values of all numeric columns

For a non-JSL solution...

  1. From the columns red triangle in the colmns panel (left side of data table) select "Column Viewer".  
  2. Select the columns of interest
  3. Click on the "Show Quartiles" option
  4. Click Show Summary
  5. From the Summary Statistics red triangle menu select "Data Table View"
  6. Delete the columns you do not want.
  7. Done.