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
The 1st thing I wish I knew when I started scripting: There are different kinds of scripts

Once more unto the breach!

I was talking with my dad a few weeks back. Not to date him, but he’s been using JMP since version 1.0. I remember seeing the 3.5” discs sitting next to our Mac II-se when I was first learning to use a mouse. The same machine was on display at the 2019 Discovery Summit conference in Tucson, Arizona. Here’s a picture of it:

 

IMG_0508.jpeg

Anyway, my dad and I were discussing my first Five Things blog series. He mentioned that he wished someone would write a series about how to get started with scripting in JMP. At the time, I was already in the process of writing some other articles, so I tucked it away for a future project. Life, however, had other plans. A week later, I was asked to help with a customer presentation and, to my surprise, one of the topics they wanted me to cover was an introduction to scripting! The universe loves jokes, apparently.

Anyway, here we go again! Following the format of my first Five Things series, here are the five(ish) things that I think everyone should know when they are starting to script. Up first, a conceptual thought.

See a need, fill a need

Before you start scripting, you need to consider the need. Odds are, if you want to script, there is some reason. Maybe you’re doing it to make yourself more efficient at work. Maybe you’re looking to standardize analytical methods for a group. Or maybe you are, in fact, one of those rare people that decided to pick it up for grins and giggles. None of these are bad reasons, although the last one may make things a little more difficult (I’ll explain why in a bit). The point is that you should have a reason in your head and a specific purpose for your first script.

There are scripts, and then there are scripts

There are, in my mind anyway, two different types of scripts: those that act on existing data, and those that create data. Scripts that work on existing data interact with a data table and existing platforms in JMP to create a new user defined output. These can be things as simple as wrapping a window around multiple reports or as complex as a custom-built report in Application Builder. The key commonality is that scripts like this are modifying existing content.

The second group are scripts that create data. Scripts that create data can be simulation tools, custom graphics, tools for managing metadata in a JMP file, etc. This group is a little more nebulous, but the common theme is that the scripts extend JMP in ways beyond enriching existing data or analyses. Most of the time, these scripts are going to create new content from scratch.

Scripts that modify existing content are generally where people start when they think about learning JMP scripting language (JSL). This is also where we are going to start our discussion. So, let’s take a step back and think about why you are interested in learning JSL.

Give me a sentence, Vasily. One sentence only, please.

Take a moment and think about your need. Which pain point are you hoping to address with JSL? Do you now see why scripting for grins and giggles (at least at first) can be tricky? You’re much more likely to fight up the learning curve if you’ve got a reason to reach the top. I’m not saying you can’t pick up JSL for the heck of it, just that the fight is harder without the extra motivation.

The next step, and the final one that we’re going to cover in this episode, is what you do with that need. The simple answer is that you are going to do two things. First, you are going to write down that (possibly nebulous) idea that’s driving you to learn JSL into a single sentence – a problem statement. And, I do mean just one sentence. Make sure you are able to crystallize the idea into something tangible that you can build off of. It will also help with reining in scope creep. Here are some examples:

  • I want to automate all the graph generation for my weekly report into one script.
  • I want to automate the formatting work for a customer provided data table.
  • I want to generate a set of control charts from a data file provided by my factory computer system. 

Note that I’m not talking about specifics; I am simply stating the pain point that has me looking at JSL. And then I stopped writing.

Make your punch list

Got your problem statement? Good! Now we are going to write a series of specific deliverables for your script. It will be our punch list to help us locate the resources SAS provides for learning JSL. Do not list any graphical user interface (GUI) or user interface (UI) specifically. List the actions that the script needs to perform. Here are examples for the problem statements above:

Problem Statement 1: I want to automate all the graph generation for my weekly report into one script.

Punch List:

  1. Pull a data set from our production database containing the last three weeks of data.
  2. Make a graph of time vs temperature for my product.
  3. Run an analysis of time vs temperature using a polynomial model.
  4. Export the graphs and reports to a PowerPoint file.

Problem Statement 2: I want to automate the formatting work for a customer provided data table.

Punch List:

  1. Rename columns based on internal standards (using table from specs).
  2. Assign units to the needed columns (using table from specs).
  3. Convert Lat and Long to Geographic coordinates.
  4. Change defective units column from continuous to ordinal.

Problem Statement 3: I want to generate a set of control charts from a data file provided by my factory computer system.

Punch List:

  1. Import data from network location.
  2. Assign spec limits.
  3. Build control charts.

Note here that I’m not boxing myself in too much. I’m just building a punch list of things I need the script to do. Since I’m assuming that you’ve never worked in JSL before, I’m also assuming that you don’t know how you’re going to attack these problems. By writing them down, you know what you need to look for in the help and resources. Which is where I will pick up in the next installment of this series.

Closing thought for this week

Since this series is going to span a few weeks, I decided to make it more of a work-along series than something you just read. So, take these last points I made as homework. If you want some accountability or feedback, put them in the comments below. I’ll chime in if I can help or let you know if you might be setting yourself up for some trouble down the road.

For bonus points, open up a script window in JMP (File > New > Script) and put your problem statement and bullet points into the script window, one per line with a double forward slash (“//”) at the start of the line. You may see the text color change to green for those lines in the JSL Script Editor. We’ll cover what you just did in an upcoming episode.

Oh, and if you’re wondering who Vasily is and why he should be giving you a singular sentence have a look here.

 

Last Modified: Apr 26, 2022 3:47 PM
Comments
rKonyndyk
Level I

Good thoughts.  For learning JMP, the new edition of Jump Into JMP Scripting, by Murphrey and Lucas was helpful for me.

MikeD_Anderson
Staff

Great thought! Have a look in part 2 of the series for some additional helps: The 2nd thing I wish I knew when I started scripting: Getting help 


Best,

M