Subscribe Bookmark RSS Feed

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

akash_nigam_gma

Community Trekker

Joined:

Jan 15, 2015

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

Joined:

Jun 22, 2012

Solution

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
4 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

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));
 
akash_nigam_gma

Community Trekker

Joined:

Jan 15, 2015

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

Staff

Joined:

Jun 23, 2011

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

Joined:

Jun 22, 2012

Solution

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