cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
Choose Language Hide Translation Bar
hogi
Level XII

Tips and Tricks - best practice with JMP/JSL

There is a wonderful blog post by @Craige_Hales : How Do You Draw a Circle? 

It nicely illustrates that there are multiple solutions to every problem - with varying degrees of success in achieving the goal and in investing ressources.

 

And often there is not the ONE solution with maximum points in all categories:

  • goal was met
  • length of code
  • speed (to write the code)
  • speed (to execute the code)
  • complexity (to understand the code)
  • complexity ( to remember the code)

 

Examples:

topic standard approach faster/optimized approaches links
General      
learn scripting trial and error watch the recordings of theJSL Scripters Club Meetings  
       
Data import      
open multiple data files use open()  (inside a for loop) use MFI
(faster csv reader!)
Open multiple Files
get a list of files generate the file list - via Python, command prompt etc. and paste it into a new JMP table MFI
→ right click on file list → Make into data table
 
find a file in a deep/complicated network tree structure use MFI or Windows File dialog create a wrapper for Python/GLOB   
       
Data tables      
change column entries step by step via for loop data table subscripting Data table subscripting
  ...

 dt << begin/end data update;
before/after the loop

Very slow loop behaviour
add columns to a data table merge data tables via Tables/Update first aggregate via Tables/Summary
then merge via Tables/Update
Speed up Tables/Update
column aggregation
with restrictions

with a character comparison Col(if(... gets very (!!!) slow:
col Max( if(:sex=="M", ...)

a) use if(:sex==1,...)

How-do-I-use-the-Col-Maximum-Formula-with-a-where  
(fixed in V19)
 

... 

b) replace :sex=="M"
with contains(:sex,"M")

How-do-I-use-the-Col-Maximum-Formula-with-a-where
 count words e.g. count xxx in :col:
N Rows(loc(Words(:col),"xxx"))

(Length(:col)-

Length(Substitute(:col, "xxx", ""))

)/3​

 

Count number of occurrences of specific words in a string

rank unique

New Column( "rank_unique",

Formula( Col Minimum(

Col Rank( If(

Row() == Col Min( Row(),

:age, :sex ), 1 ), :age ),

:age,:sex)) 

Col Score(:age, :sex)

(v19)

Add dense ranking to Ranking Tie and Col Rank functions

Recode  hogi_0-1730275949272.png

can be very slow in combination with other options

apply the option in a second step

Recode - Parse as Number

replace values with other values for loop or Recode use DataTable subscripting Replace missing values with 0
Should you Loop through a data table or use Recode, or use Get Rows Where to change values in a data...
select rows based on a formula If dt << select where() is too slow
... split it into 2 steps:

myrows= dt << get rows where();

dt << select rows(myrows)

Formula to check if any of a list of items is contained in the rows of a column
spec calcualations some manual JSL code support this wish with a Kudo:  🙏 is in spec (value)
       
Graphs      
       
       
Reports      
       
       
Export      
       
       
       
Database access      
       
       
       
Neural Networks      
       
       
       
...      
       

 

 

[More Topic Containers like this]

1 ACCEPTED SOLUTION

Accepted Solutions
hogi
Level XII

Re: Speeding up JMP/JSL

-> Table moved to main post.

View solution in original post

7 REPLIES 7
jthi
Super User

Re: Speeding up JMP/JSL

It depends a lot on what you are doing. Some good general tips can be found from Scripting Guide > Efficient Scripts 

-Jarmo
hogi
Level XII

Re: Speeding up JMP/JSL

Thanks, a good place to start ...

 

Going further, how about a list with as many entries as possible along the idea:
If you want to do this, you probably thought of this approach - but concerning speed, the other approach is much better!

 

Who is interested in sharing his secrets

hogi
Level XII

Re: Speeding up JMP/JSL

-> Table moved to main post.

hogi
Level XII

Re: Speeding up JMP/JSL

I added a cool trick to count words by @ian_jmp :
Count number of occurrences of specific words in a string 

hogi
Level XII

Re: Speeding up JMP/JSL

hogi
Level XII

Re: Speeding up JMP/JSL

Wonderful talk on XPath & Subscripting in Reports:
 https://community.jmp.com/t5/Abstracts/I-Can-See-It-How-Do-I-Get-It/ev-p/776041 

hogi
Level XII

Re: Speeding up JMP/JSL

JM 19:

column aggregation
with restrictions

with a character comparison Col(if(... gets very (!!!) slow:
col Max( if(:sex=="M", ...)

a) use if(:sex==1,...)

How-do-I-use-the-Col-Maximum-Formula-with-a-where  
(fixed in V19)
rank unique

New Column( "rank_unique",

Formula( Col Minimum(

Col Rank( If(

Row() == Col Min( Row(),

:age, :sex ), 1 ), :age ),

:age,:sex)) 

Col Score(:age, :sex)

(v19)

Add dense ranking to Ranking Tie and Col Rank functions

Recommended Articles