Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Newbie2Jumpie
Level IV

How to write a single value into a global macro variable (scripting)

I know one simple way is:

my_var= 123;  [kudos to Tx!]

 

What I would like to do ist to automatically write a single value into a global macro var based on a condition, something like:

 

my_var2= (numeric, continuous, formula(if(:Condition1=="yes" & :Condition2 ==23.4, :SourceValue"));

 

Take the SourceValue value that has Condition1="yes" and Condition2=23.4 and write it into the global macro var MY_VAR2.

 

I am thankful for every pointer!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: How to write a single value into a global macro variable (scripting)

Here is one way to do what you are looking for

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/big class.jmp" );

// Get Rows Where, returns a matrix of all rows that meet the criteria,
// so one needs to select the 1st matrix element 
my_var = :weight[(dt << get rows where( :sex == "F" & :height == 66 ))[1]];
Jim

View solution in original post

1 REPLY 1
Highlighted
txnelson
Super User

Re: How to write a single value into a global macro variable (scripting)

Here is one way to do what you are looking for

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/big class.jmp" );

// Get Rows Where, returns a matrix of all rows that meet the criteria,
// so one needs to select the 1st matrix element 
my_var = :weight[(dt << get rows where( :sex == "F" & :height == 66 ))[1]];
Jim

View solution in original post

Article Labels

    There are no labels assigned to this post.