cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

How to name a table via JSL and reference it later in the script?

Hi I am trying to select a small subset of data from a big datatable and create a temporary table out of it. The overall objective is to  sumarize the subset data. The script below is creating the subset data table "Name" but it is not returning the reference to it for me to process the new table. In the script below it is summarize the data of Test data table but not the Name data table.

Please help me with it.

 

 

 

dt=Open("Test.jmp");
Z= NRow();
 
k=dt<< Get Rows Where(:Para == "THK" );
pt = dt << Subset(
Rows(k),
Output Table Name("Name"),
);
 
// I want to summarize the data from this subset  data table
Close (dt, No Save);
 
 
pt = Current Data Table ();
 
Summarize(
  a=by(:Para, Route),
  //b= by(:Route),
  c= count,
  meanHT = mean(SITE_VALUE),
  stdevHT = stddev(SITE_VALUE)
);
 
show (a,c);

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Reference to the Output Table Name

I might be missing something, but from the original question, the issue stated seemed to be the need to be able to reference the subsetted data table for the summarize function.  In JMP 12, there is an additional argument available to the summarize function.  You can add the data table as the first argument.  So all you would need to do is to change the summarize statement to:

 

Summarize(pt,
  a=by(:Para, Route),
  //b= by(:Route),
  c= count,
  meanHT = mean(SITE_VALUE),
  stdevHT = stddev(SITE_VALUE)
);

Another observation is that you were using a statement of:

 

pt = current data table();

 What I believe you really wanted to do is to set the current data table to pk, by using:

current data table(pk);

Or am I completely misdirected?

Jim

View solution in original post

7 REPLIES 7
ian_jmp
Level X

Re: Reference to the Output Table Name

Perhaps the JSL equivalent of 'Tables > Summary' is better in this case?

 

NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
rows2get = dt << getRowsWhere(:sex == "F");
dtSub = dt << Subset(Rows(rows2get), Output Table("Females"));
dtSummary = dtSub << Summary(Mean(:Weight), Group(:age));
 

Re: Reference to the Output Table Name

Thanks. It seems to solve my original problem. .

Infact my original script also seems to work just does not allow me easy handling of datatable object. Like in the present case (using your script), I am not able to save the Subset Table. Any suggestions?? Thanks in advance

Close (dtSub, Save);

throws an error.....

I/O problem. Unable to open in ReadWrite mode.

The system cannot find the file specified.

Save changes to the JMP Data Table Female?

ian_jmp
Level X

Re: Reference to the Output Table Name

If you use the 'Save' option of 'Close()', you need to tell JMP where to put the file:

 

NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Wait(3);
Close(dt, Save("$DESKTOP/"||(dt << getName)));
txnelson
Super User

Re: Reference to the Output Table Name

I might be missing something, but from the original question, the issue stated seemed to be the need to be able to reference the subsetted data table for the summarize function.  In JMP 12, there is an additional argument available to the summarize function.  You can add the data table as the first argument.  So all you would need to do is to change the summarize statement to:

 

Summarize(pt,
  a=by(:Para, Route),
  //b= by(:Route),
  c= count,
  meanHT = mean(SITE_VALUE),
  stdevHT = stddev(SITE_VALUE)
);

Another observation is that you were using a statement of:

 

pt = current data table();

 What I believe you really wanted to do is to set the current data table to pk, by using:

current data table(pk);

Or am I completely misdirected?

Jim
Ressel
Level VI

Re: Reference to the Output Table Name

What's the difference between

pt = current data table();


and

current data table(pk);


?

 

Ryan_Gilmore
Community Manager Community Manager

Re: Reference to the Output Table Name

 

pt = current data table();

will get the current data table

 

 

 

current data table(pk);

will set the current data table

 

Re: Reference to the Output Table Name

The first is a question and the second is a statement.

 

It is often efficient when working with a data table to obtain a reference to it and then re-use it to send messages. The first usage is calling the function to obtain that reference and storing it in a variable for future reference.

 

The current data table is a convenience in that most action in JMP defaults to that table if one is not explicitly specified. The second usage assigns a table reference to make it the current data table. Imagine that you have several tables open and want to switch one table to be current.

 

This provision in JSL is a matter of style. It also depends on the use case if one style is more advantageous than one style.