Choose Language Hide Translation Bar
Community Trekker

## 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
Highlighted
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
Highlighted
Community Trekker

## Re: Min and Max values of all numeric columns

``````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
3 REPLIES 3
Highlighted
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
Highlighted
Community Trekker

## Re: Min and Max values of all numeric columns

``````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
Highlighted
Super User

## 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.