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
lwx228
Level VII

How do find the serial Numbers of two columns in a table directly from their data?

Take this sample form.

dt = Open( "$SAMPLE_DATA/Lung Cancer.jmp" );


Columns 1 and 2 comprise data that does not duplicate.
Now what do want to do for JSL to find a single serial number that combines "NonSmoker" and "Cancer"?

Let's say have a lot of rows.

 

2020-06-26_20-25.png

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: How do find the serial Numbers of two columns in a table directly from their data?

The issue is that JMP is getting confused on how to construct the final outcome of your statement

r=dt<<get rows where(:smoker=="NonSmoker" & :lung Cancer == "Cancer" )[1,1];

If you use a pair of "()" to help JMP understand that [1,1] is talking about what is returned from the Get Rows Where(), your code will work.  

r=(dt<<get rows where(:smoker=="NonSmoker" & :lung Cancer == "Cancer" ))[1,1];
Jim

View solution in original post

5 REPLIES 5
Highlighted
txnelson
Super User

Re: How do find the serial Numbers of two columns in a table directly from their data?

?????

dt = Open( "$SAMPLE_DATA/Lung Cancer.jmp" );
show(dt<<get rows where(:smoker=="Smoker" & :lung Cancer == "Cancer" ));
Jim
Highlighted
lwx228
Level VII

Re: How do find the serial Numbers of two columns in a table directly from their data?

Thank Jim!

Yes, exactly.

2020-06-27_14-01.png

How do  get

r = 3

Rather than

r = [3]

 

Highlighted
lwx228
Level VII

Re: How do find the serial Numbers of two columns in a table directly from their data?

Matrix

dt = Open( "$SAMPLE_DATA/Lung Cancer.jmp" );
mat = dt << get rows where( :smoker == "NonSmoker" & :lung Cancer == "Cancer" );
r = mat[1, 1];
  • But I don't understand that if I write this directly, it won't work:

    dt = Open( "$SAMPLE_DATA/Lung Cancer.jmp" );
    r=dt<<get rows where(:smoker=="NonSmoker" & :lung Cancer == "Cancer" )[1,1];

    Thanks!

Highlighted
txnelson
Super User

Re: How do find the serial Numbers of two columns in a table directly from their data?

The issue is that JMP is getting confused on how to construct the final outcome of your statement

r=dt<<get rows where(:smoker=="NonSmoker" & :lung Cancer == "Cancer" )[1,1];

If you use a pair of "()" to help JMP understand that [1,1] is talking about what is returned from the Get Rows Where(), your code will work.  

r=(dt<<get rows where(:smoker=="NonSmoker" & :lung Cancer == "Cancer" ))[1,1];
Jim

View solution in original post

Highlighted
lwx228
Level VII

Re: How do find the serial Numbers of two columns in a table directly from their data?

Thank Jim!
I'm still learning basic grammar.
Article Labels