cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

Creating Scripts Automatically and Saving Scripts

Started ‎11-08-2022 by
Modified ‎11-08-2022 by
View Fullscreen Exit Fullscreen

So this demonstration, we'll look at the various ways that you can create and save JMP scripts. So I'll begin by interactively creating a new column with a formula where I calculate the standardized value of the tensile strength of concrete. So in the journal in section I'll click Concrete Strength Data. So to create my new column of the standardized strength, I'll go to the Columns menu and select New Columns. I'm going to type Standardized Strength as the column name. And I'll go to the Column Properties dropdown menu, and at the very top, select Formula. The standardization I'm going to use is simply each observation, each value of strength, minus the column mean of strength divided by the column standard deviation of strength, which is a common standardization that will result in values that have a mean and standard deviation And in fact, this transformation is so, or the standardization is so common that we have a single function that will do it. But I'm going to break it up into the component parts just so that we can have two functions in our script that I'm storing in this column. So I'm going to expand the list of statistical functions by clicking the gray triangle on the left-hand side of the formula editor window. And to start the formula, I will click Strength in the list of columns in the middle. I'll click the subtract sign. And then from the list of statistical functions, I'll select Col Mean, and then I'll select Strength from the list of columns again. So I have the numerator, which is each value of Strength minus the column mean of Strength. I'll click to highlight that entire difference in the blue outline, and then click the Divide button. And then over in the functions under statistical, I'll select Col Standard Deviation, and again, I'll select Strength. And again, we can do the same standardization with a single function, Col Standardized, but for purposes of illustration, I wanted to have two functions in the formula. Now, I can view this as a script. That's what it is. I can view it in a more typical JSL view by simply double-clicking. And here, now again, we see those colon scoping operators ahead of the column name. One thing we also see that we'll see in our script editor windows is that the functions are - the text of the functions is colored blue. And that actually is helpful for us to see that JMP recognizes that this is a built-in function. But you can see that when I hover over the function name, I get the syntax and a description of that function. So that's one way that we can learn about functions-- one of many ways. One nice thing about this is that if I were writing a script that had a complicated formula in it, I could use the formula editor to build it-- and I'll cancel out of here-- to build it in a way that, in this interface, is very easy to see what's in the numerator, what's in the denominator, and so on. And I could then simply copy this-- either right-click and copy or use your Ctrl+C when it's highlighted-- and paste it into my script. And so I don't have to write out complicated formulas or equations just in one line in the script editor. I can take advantage of this nice visual interface of JMP's formula editor and grab the formula and put it into my script. And then I don't even have to keep the column if I didn't need it. So I've got this script. These are all JSL functions on the left-hand side. I've got this script that I'm going to store in an individual data column. I'll click OK. And if I was going to keep this, table I would probably change the format here as well. We'll see how we can create new columns and change formats with scripts later on. But I'm going to go ahead and click OK. And there you can see that formula column in my data table. So again, that's one way that a script can be saved in a data table column where the only place that script executes is in that specific context. Let's take a look at how we can save scripts for an analysis for future use. So again, I'll start interactively by going to the Analyze menu and Fit Y by X. I'll put Strength in that Y role, and then I want to put Type in the X role. And just like with Bivariate, JMP chose the appropriate platform based on the modeling types in my X and Y roles. So here, that's going to be one-way. And I'll click OK. And then for the analysis, I'll go to the red triangle next to One-Way Analysis and select the Means/Anova. And there are several ways that I can get JMP to generate a script, several ways that I can save that. I'll go to the red triangle next to One-Way Analysis, and under Save Script, you can see that we can save it back to the data table. So it'd be saved in the table panel and run just in the context of this data table. You can save a script to a journal and in this case, I have an open journal, so it would save to that journal that I have open. And that script would actually include the instructions to not only do this analysis, but first to open the data table associated with the analysis. We can save scripts to a script window. We'll be doing that throughout the course. You can save a script to the report, so the syntax-- the code for this analysis-- would appear in the analysis window. And then you can also save a script to the Clipboard if you just need to paste it into an email or some kind of presentation. I'm going to go ahead and save this one to the script window. And here, I can see the entire script. So if I right-click and reformat the script, nothing happens. Again, all I have to do is resize it so I can't see the entire thing. Right-click, reformat, and that kind of forces JMP to do that. There is actually a toolbar button for reformatting the script, and the keyboard shortcut Ctrl+M can also be used. And just like you saw before, the script is pretty recognizable using the same words that we see when we are interacting with JMP through mouse clicks. That object is my one-way platform. We have the columns cast into the analysis roles Y and X. And we have arguments from the red triangle menu to request specific analyses, including the Boolean turning those options on. So now I'll return to the course journal and click Delete All, Save None. And I will not save changes to my script window.