cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar
Nuroffen
Level II

Write in columns calculated values

Hello, 

 

I have a project and my purpose is to extract from my data table (1) the average, maximum and minimum value for each column, and write the results into a new table (2). 

I found this part of the code and it seems to work for few columns, but not for all. I have like 300 columns and I have the results for only twenty of them.

 

For( i = 1, i <= N Col( dt ), i++,
	If (:Trial[i] =="TrialName",
		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 ) ) );
			Write( "\!nAverage: ", Col Moving Average( Column( dt, i) ) );
			Write ("\!n");		
			)
		)
   );	

I can see the results in the logs but I don't manage to write the results in the right column of my new table (2).

 

View more...

This code shows something like : 

Column 1

Min : 10

Max : 50

Average : 30

 

 

Here is an example of what I want :

 

Table 1:     Column 1 :   Column 2 :                --> Table 2       -----> Column 1 :             Column 2 :

                  10                 45.2                                                           Max : 50                Max : 52.4

                  20                 48.3                                                           Min : 10                 Min : 18.3

                  30                 36.7                                                           Average : 30          Average : 40.18

                  40                 52.4

                  50                 18.3

 

--->

1. I think all my data are not considered as numbers so JMP doesn't want to calculate min, max and average, but I didn't find a way to "force" the type of the data.

2. I don't manage to write my results in the columns of the final table (2).

 

I don't ask for the full answer but only for tips because I'm really stuck. 

 

Thank you !

4 REPLIES 4
jthi
Super User

Re: Write in columns calculated values

To write to other table you could use some of these Add Rows() or New Column(). Write() will just print the values into the JMP Log. Then there is also Data table subscripting , you could possibly use Tabulate() or Summary() to calculate the statistics (maybe even Distribution in combination with make into datatable).

For "forcing" values to be numeric (be careful with this, as this can and will result in a data loss) you could try using << Set Data Type("Numeric")

 

For more info on functions see Scripting Index in JMP's Help menu

-Jarmo
txnelson
Super User

Re: Write in columns calculated values

The project that you described can be generated in JMP by using one of the built-in JMP Platforms.  And once the platform is run interactively, the JSL to run it can be obtained directly from JMP.  I suggest you take a different route to your solution.

Below are he beginning data table and resulting data table after running the platform.

txnelson_0-1650020145515.png

txnelson_1-1650020204288.png

 

 

Jim

Re: Write in columns calculated values

You can get what you want using JMP interactively. I will illustrate with Fitness from the Sample Data folder. Assume that the data table is open.

 

Step 1: Compute statistics

  1. Launch the Distribution platform with all the data columns of interest (Age through MaxPulse).
  2. Right-click on the Summary Statistics table and select Make Combined Data Table.

Step 2: Re-arrange results the way you want.

  1. Select Tables > Split. Select Y column and click Split By. Select Column 2 and select Split Column. Select Keep All. Click OK.

distribution.PNG

combined.PNG

split.PNG

new table.PNG

I mean only to illustrate a quick, interactive process. It can be captured in a script as @txnelson suggested. It can be customized at each step as necessary.

 

 

 

Nuroffen
Level II

Re: Write in columns calculated values

Thanks to all of you for the tips ! I will work on that during next week.

I have read everything, I didn't knew it was possible to do this with JMP presets. 

 

My point is to run one script to have the final result for an easy use of everyone. I think I can script the step you showed me.

 

thank you !