Choose Language Hide Translation Bar

Using JMP for Everyday Automation (2022-US-30MP-1143)

While JMP is definitely a time-saver in the world of statistical problem solving, with a small amount of up front JSL scripting, JMP also can be a huge time saver for the more mundane aspects of daily work. This presentation demonstrates how to free up time for more meaningful work using JSL to automate daily workflows, send automatic reports as emails, perform automated file management and more. While there will be some scripting involved, this presentation is accessable to all, as JMP will do most of the heavy lifting (scripting). The presentation is live demonstration using JMP only.

 

 

Hi,  this  is  Jed  Campbell.

I'm  here  to  present  today   on maybe a  little  bit  different

than  what  we  normally  think  of   as things to go and  learn  about

at  Discovery.

It  turns  out  that when  you  really  look  at  it,

there's  two  things  that  we  all  do.

There  are  two  things  that  we  all  do,

and  really,  it  comes  down  to  the  things that  we want to do in life

and  the  things that  we  don't  want  to  do  in  life.

I  think  Randall  Munroe summed  this  up.

In  the  last  few  years, we've  all  spent  a  lot  of  time

doing  things  that we  don't  really  want  to  do.

But  that  comes  down to  the  same  at  work  as  well.

I  think  a  lot  of  the  time  when  we  come to  JMP  Discovery,

we  want  to  focus on  the  things  we  want  to  do.

We  want  to  focus  on  learning  how  to  do

better and  faster  analysis, more  statistical  tools.

Today,  I'm  actually  going  to  focus on  the  things  that  we  don't  want  to  do,

the  mundane  tasks that   make  life  less  worth  living,  I  guess.

We're  going  to  focus  on  ways  to  make those  simpler,  better,  and  faster  more.

But  before  we  begin,  I  want  to   maybe talk  a  little  bit  about  history.

In  1981,  I  remember  my  dad   came home  with  our  first  computer.

It  was  a  Commodore  VIC- 20, had   4k  of  Ram,  and  I  had  to  look  this  up,

but  a  1- Megahertz  processor, and  it  was  an   8-bit  processor.

A nything  we  wanted  to  do  in  that, we  had  to  program.

I'm  presenting  today  on  a  basic  laptop that  you  can  buy  at  any store

with  16  gigs  of  RAM, a  super fast  processor,

and  64  bit  processor.

Really  it  comes  down  to

what  is  the  difference between  a  million  and  a  billion?

Notice  that  we  have  a  log  scale  here.

This  Commodore  V IC-20 was  at  the  beginning  of  things,

and  now  we're  somewhere  in  this  range.

Essentially,  the  difference   between a  million  and  a  billion

is  a  billion.

Or  the  difference

between  an  old  school  processor   and current processors  is  almost  infinite.

What  that  means  is  that while  elegant  code  can  feel  good  to  write

and  can  execute  a  little  bit  faster, it's  really  hard  to  decipher.

Brute  force  code,  on  the  other  hand, is  lazy  and  easy  to  read.

The  good  news  is  there  are  plenty of  CPU  cycles  for  a  brute  force  approach.

That's  what  we're  going to  be  talking  about.

I  don't  think  we  need to  do  anything wild or crazy

to  make  mundane  tasks more  easy  for  us  in  JMP.

Before   I  begin,

I  just  like  to  say  nobody  likes to  be  watched  using  a  computer.

Obviously,  if  something  goes  wrong, this  journal

is  already  available on  the community.jmp.com,

and  we'll  make  it  work.

But  anyway.

Also,  shout  out  to  the   Scripting Index.

I  want  to  make  sure  that

if  you  find  yourself doing  scripting  in  JMP,

that  you  should  probably  set a  keyboard  shortcut

for  the   Scripting Index   because it  really  speeds  things  up.

A  way  to  do  that  would  be to  come  up  to  the  View  menu.

View,  Customize,  Menus  and  Toolbars, and  then  you  can  find   Scripting Index.

I've  already  assigned

the  keyboard  shortcut of  Control  Shift  X.

I  can  just  reassign  that  right  now.

What  that  means  is  anytime  I  want to  see  the   Scripting Index,

I  can  hit  that  Control  Shift  X, and  it  pops  up.

Super  useful,  and  I  use  it  a  ton.

This  little  button  right  here is  going to make a folder

because  we're  going  to  be  doing some  file  manipulation.

I'm  just  going  to  hit  the  OK  button, and  now  I  have

a  folder  with  an  Excel  document  in  it and  a  PowerPoint  document  in  it.

For  those  of  you familiar  with  demos  in  JMP,

you  may  see

that  this  Excel  document  looks suspiciously  like  big  class

because  that's  what  it  is,   as well as the  PowerPoint  document.

But  we're  going  to  be  messing  around with  some  of  those  things

in  a  little  while.

That  all  being  said,  let's  get  started.

As  we  talk  about  things  that  we  don't necessarily  want  to  do  but  must  do.

I  work  in  a  quality  group,

which  means there  are  a  lot  of  requirements

that  customers  have  for  us,

that  governing  bodies  have  for  us that  just  need  to  be  done.

I  could  spend  a  lot  of  time doing  those  things.

Or  I  could  make,  for  example, a  few  little  dashboards.

These  are  dumbed  down  versions of  those  dashboards.

They're  all  functional  in  here if  you're  going  through  this  journal

on  your  own  later.

For  example,

somebody  emails  you  a  folder   and emails you  something  in  Excel,

and  you  have  to  do something with it,  or  you  have  to  send  emails  to  people,

you  have  to  do  some  work  in  some  weird

random  network  folder that  you  can  never  remember.

But  we'll  go  through  some  of these examples  together,

but  just  know  that  those   are there  to  interact  with  later.

First,  let's  talk  about the  web  command  in  JSL.

It  turns  out  it's  not  just  for  websites,

and  it's  actually,  sure, you  can  open  a  website  with  it,

but  you  can  also  open  a  file from  a  SharePoint,  or  a  Google  Doc,

or whatever  cloud  service your  organization  uses.

You  can  open  a  folder  on  your  computer.

You  can  also  open  a  non-junk  document

in  its  native  thing  because  remember, the JMP, it's  more  like  saying,

"Computer,  do  something  for  me   the way you're  used  to  doing  it."

For  example,  we  can  open an  Excel  file  in  Excel,

if  you  ever  need  to  do  that.

You  can  also  use  it to  compose  an  editable  email.

In  fact,

looking  on  Wikipedia,  URI   or  Uniform  Resource  Identifier

is  a  special  way  that  computers   can do  all  sorts  of  things.

You  can  tell  your  computer, as  I'm  scrolling  through  all  of  these,

apparently,  there's  an   ed2k  thing, if  you  know  that.

If  you're  on  an  Apple  computer, and  you  want  to  FaceTime  someone,

you  can  use  this  protocol  to script that.

Microsoft  computers, you  can  do  the  same  thing.

There's  a  whole  bunch  of  config  settings.

You  could  use  to  take  cameras,

take  pictures  with  the  camera, or  change  notifications.

The  list  is  pretty  much  endless.

Let's  actually  dive  into  it  now.

This  button  here.

Okay.

Again,  we've  seen,  and  we   think that  the  web  command.

Yeah,  of  course  it  works for  opening  web  addresses.

If  I  use  the  Enter  key on  my  numeric keypad

that  runs  that  line  of  the  script, and  that's  what  I  expect.

We  can  also  copy  and  paste, like  I  mentioned  before,

URL  from  a  SharePoint  site and  make  a  link  to  that  with  JMP.

You  can  use  it  to  open  a  folder.

Here  is  the  shortcut  to  open that folder

that  we've  been  working  with, that  we're  going  to  be  working  with.

You  can  open  a  non-JMP  document  with  it.

Instead  of  using  the  open  command, you  would  use  web,

and  here  is  a  PowerPoint  document.

You  can  open  an  Excel  file   in JMP  or  in  Excel.

Using  the  open  command  here is  something.

If  I  run  this  line, it  will  open  that  Excel  file

that's  in  our  folder  in  JMP.

But  if  that's  not what  the  behavior  that  I want,

I  can  use  the  web  command  instead and  it  will  open  that  file  in  Excel.

If  I  need  for  some  reason  a  feature that  only  Excel  has,

or  I'm  working  with  people that  don't  have JMP.

This  is  where  it  gets  more  fun.

I  just  chose  the  mail to  URI  scheme   as something  to  experiment  with.

This  is  just  an  online URL  mail to  generator.

We  can  open  this  and  we  can  say, to  test@example.com.

What's  the  subject?  JMP.

Is  great,  lots  of  exclamation  marks.

Then  it  will  generate  that  URL  for  me.

A ll  I  have  to  do  is  CTRL  C to  copy  to  my  clipboard.

Then  I  can  come  in  here  and make  a  new  line.

Web,  open  quotes,  paste  that  in, put  my  semicolon  at  the  end.

Now  I  get  an  email  pop- up that  I  can  edit  before  I  send  it.

Sometimes  that's  really  nice.

JMP's  mail  command  doesn't  allow  you to  modify  an  email  before  you  send  it.

For  example,  if  you  have  a  long  list

of  people  that  need  to  be  emailed, but  you  want  to  personalize  each  message

before  you  send  it,

this  is  a  way  to  do  that.

I'm  not  going  to  go  ahead  and  send that

because  I  don't  want  those  people to  get  bombarded.

A gain,  here's  another  list  of  URI  schemes.

There  are  tons  of  ways  to  do  that.

We  just  chose  the  mail to  one as  an  example.

That  being  said, we've  learned  one  way  to  do  mail.

If  you're  not  familiar with  JMP's  built- in  email  command,

let's  go  over  that,

and maybe  say,  for  example, you  have  a  report  or  a  dashboard

that  you  output  and  you  need  to  email a  bunch of people,

but  they  don't  all  necessarily  have  JMP.

Let's  walk  our  way  through  opening a  data  table,  and  running  a  script on it,

and  then  saving  that as  an  interactive  HTML,

and  then  we'll  email  that.

In  this  case  here, I'm  just  going  to  tell  JMP

to  open  the   Big Class  data  table from  its  sample  data  folder,

and  store  that  in  something called  data  table bc, dtbc

for Big Class data table.

Then  I'm  going  to  tell that  Big  Class  table

to  run  the  script  that's  already saved  to  the  table  called  Bivariate,

and  do  that  in  a  new  window  called  NW.

Then  all  I  need  to  do  is  tell  NW to  Save   Interactive  HTML.

I  should  if  everything  works  right,

I  probably  could  have  scripted  this to  close  automatically  for  me.

But  I  need  to  get  to  that  folder now  that  I've  closed.

I'm  going  to  cheat  a  little  bit and  open  this  folder.

Now  it  has  that  report that  htm,

and  back  to  our  regular  program  here.

Now  I  can  run  this  line,  and  JMP  will  automatically  open  it

in  my  default  web  browser.

If  I've  got  that  file,

and  now  I  want  to  email  it  to  people.

It  should  be  relatively  simple  for  me,

but  it  turns  out  it's  maybe  a  little bit  more  complicated  than  you'd  expect.

If  you  have  a  static  list  of  people you  want  to  email,

like  test and test2 @example.com,

"Hey,  here's  your  monthly  reminder to  do  the  thing,"

and  I  want  to  attach  this  file that  I've  done,

I  can  select  those  lines,  I  can  run  them.

My  organization  is  going  to  pop  up a  little  Allow  or  Deny  for  each  person.

Your  security  systems   may be a little bit  different.

It's  not  perfect  yet.

I  haven't  found  a  way  to  get  around  this, but  that  just  sent  two  emails.

Now,  you  might  think   that since this is a  list  here,

that  I  could  put that list into a variable  and  then  mail it,

but  for  some  reason  it  doesn't  work.

We'll  go  ahead  and  run  it and  it'll  give  us  an  error  message.

I  tried  a  couple  of  different  ways

of  evalling  this  list,  eval,  parse, all  those  things,

and  then  I  just  thought,

"Well,  no,  I'm  more  in  favor of  brute  force  here."

One  way  to  do  it   is I  can  throw  this  into  a  list

to all  my  email  addresses, say,  there  are  47  of  them,

and  then  I  can  just  iterate through  it  with  a  for  loop.

When  we  run  that,

that  works  just  fine,  and  it  pops  up

that  message that  my  organization  requires.

That  is  another  way  to  do  it.

You  can  either  use  the  URI  scheme to  pull  up  an  editable email,

or  you  can  have  JMP do  the  whole  thing  for  you.

It  works  pretty  well.

I'm  sure  somebody  in  the  comments or  in  the  group

will  know  what  I'm  doing  wrong  here,

and  I'm  looking  forward to  learning  about  that.

But  back  to  this.

We  know  we  can  email  files.

We  can  also  do  other  things  with  files.

For example, we  can  automate creating  a  folder  structure.

At  the  beginning  of  each  year,

there  are  a  couple  of  different  places, where  I  need  to  make  a  folder

with  a  different  subfolder in  it  for  each month

so  that  we  can  figure  out where  things  are  being  filed.

Now  I  could  walk  through  in  Explorer, and I could  create  a  new  folder,

and  give  it  a  name,

and  then  go  into  that  new  folder, and  create  another new folder,

and  give  it  a  name, and  oh,  my  word,

that  just  seems  too  mundane.

I'd  almost  rather  die.

Or  I  can  just  do  it  right  here.

I  can  create  a  variable

that  is  just  the  year  that  we  are,

and  then  I  can  iterate through  months   1-12

and  create  a  directory with  the  year  and  then  that  month.

Let's  go  ahead  and  run  that,

and  then  I  should  be  able to  pop  into  this.

I  see  a  directory that  wasn't  there  before,  2022,

and  when  I  go  into  it, it's  already  done  for  me.

I'm  so  happy  I  could  cry because  I  don't  have  to  waste  my  life

manipulating  this.

That's  just  one  example and  maybe  another  example,

probably  our  biggest  example

that  we're  going  to  do  today   would be reviewing  a  list  of  files.

For  example,

part  of  my  job,  each  month, different  people  do  different audits,

and  those  audits  are  stored  in  folders.

But  those  audits,  for  example, are not stored  in  just  one  set  of  folders.

It's  lots  of  folders.

I  could  comb  through  all  of  them

to  learn  which  ones  were  done   so that  I  could  review  each  of  them.

Or  I  can  just  make  a  script  to  do  it.

Here's  the  script, which  is  a  little  bit  more  complicated,

but  it's  really  still  just  brute  force, and  it's  just  piecing  things  together.

First  that  we're  going  to  do is  we're  going  to

execute  this  code  right  here,

which  is  going  to  get  a  date, which  is  the  beginning  of  last  month,

and  this  is  being  recorded  in  July, so  that's  that  date  there.

Then  I  just  want  to  go  into  this  folder that  we've  been  working with,

and  get  a  list  of  all  the  files in  this  directory.

There's  a  recursive,

and  that  just  means  also  look  through the   subfolders  because  I  don't  want  to.

I  can  run  through  that,  and  I  can  get this  list  of  new  files  together.

Sorry,  I  can  get  this  list  of  files, and  I  can  hover  over  that,

and  I  can  see  that  it  has  the  documents we've  been  looking  at.

From  that  list  of  all  the  files,

I  need  to  know  just  which  ones were  the  new  files.

To  do  that,  I'll  create  an  empty  list.

Then  after  this  empty  list,

I'm  going  to  look  at  the  creation  date of  each  of  the  files  in  this  list.

If  that  creation  date  is  bigger  than this  date  that  I  set  earlier,

then  I'll  keep  it, and I'll say it's in  the  new  list.

That's  all  nice,  and  fine,  and  dandy, let's  run  that,  and  nothing  will  happen.

I  want  to  actually  be  able  to  see  it.

can  tell  JMP  to  show  me a  new  list  or a new window

with  a  list  box  of  those  new  files.

There  I  have  the  list.

That's  nice,  but  I  can't  really  do anything  with  it  yet.

If  I  just  copy  and  paste  this

down  here  below and  reformat  it  a  little  bit.

It's  the  same  script  as  before.

But  now  I  just  append  a  little  button  box at  the  bottom  that  says  Open,

and  I  tell  JMP  that  when  I  click  on  it,

on  that  open  button,

tell  me  what  I  have  selected,

and  then  going  back to  the  beginning  here,

use  that  web  function.

Open  that  file.

Well,  then  I  get  something

that  presents  me  with  a  list and  allows  me  to  select  each  of  them

or  one  of  them  and  hit  the  Open  button.

Honestly,  this  one  little  thing  saves  me so  much  time  each  month

and  so  much  hassle

of  trying  to  comb  through  lots of different folders

and  find  which  things  I  need  to  review.

I  think  the  lesson  of  this  is,

not  so  much  that  you  have  to  do   the exact same  things  that  I've  done,

but  more  to  start  thinking  about what  can  you  do  with  this?

Now,  I'm  not  saying that  you  could  hack  your  job

and  get  paid  to  do  nothing for five years,

that's  mostly  just  there  for  a  laugh.

But  what  I  am  saying  is  if  we  go  back

to  that  notion  of  we  all  do  two  things, the  things  that  we  want  to  do

and  the  things  that  we  have  to  do, maybe  we  can  challenge  ourselves  to  find

a  way  to  save,  I  don't  know, 30  minutes  a  week,  30  minutes  a  month,

by  automating  the  tasks that  we  don't  really  want  to  do.

That  way  then we  can  focus  a  little  bit  more

on  the  tasks  that  we  do  want  to  do.

I'd  love  to  hear  your  comments and  love  to  hear

how  you've  succeeded  with  this.

Thanks.