cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
user8421
Level II

Data Table evaluation in For Loop from a list

I keep running into an error with my script to rename data tables using a For loop.

Here's a simplified version of my script

OldNames = {"Old Name 1", "Old Name 2", "Old Name 3"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};

For( i, i <= NNames, i++,
    dt = Data Table( OldNames[i] );
    dt << Set Name( NewNames[i] );
);


I keep getting the following error

Cannot locate data table in access or evaluation of 'Data Table' , Data Table/*###*/( OldNames[i] )

However when I evaluate Data Table(OldNames[1]) there is no error!


1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Data Table evaluation in For Loop from a list

@user8421 ,

Did you successfully run @jthi's script?  If yes, then I suspect: 

  • one or more of the tables are closed
  • one or more of the tables are private
  • wrong old names.

Below is a slight modification to @jthi's script. I make the 3rd table private, and I add show statements to the For loop.

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt = Open("$SAMPLE_DATA/Quality Control/Failures3Delimited.jmp");
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp", "Private");
OldNames = {"Big Class", "Failures3Delimited", "Semiconductor Capability"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};


For(i = 1, i <= N Items(OldNames), i++,
    show(i, OldNames[i], NewNames[i]);
	dt = Data Table(OldNames[i]);
	dt << Set Name(NewNames[i]);
);

Here is the log output

 

/*:

i = 1;
OldNames[i] = "Big Class";
NewNames[i] = "New Name 1";
i = 2;
OldNames[i] = "Failures3Delimited";
NewNames[i] = "New Name 2";
i = 3;
OldNames[i] = "Semiconductor Capability";
NewNames[i] = "New Name 3";
Cannot locate data table in access or evaluation of 'Data Table' , Data Table/*###*/(OldNames[i])

at line 11 in Script.jsl

The JMP Scripting Guide states for private table that

  • Private tables are not counted when N Table() returns the number of open data tables.
  • Private tables cannot be made current with Current Data Table().

This made me think that a private table might not have the same functionality, might not have teh names stored in memory since it is not counted.

 

Good luck! 

View solution in original post

5 REPLIES 5

Re: Data Table evaluation in For Loop from a list

Hi,

 

I changed the first two arguments of the For loop accordingly.  It should work now:

OldNames = {"Old Name 1", "Old Name 2", "Old Name 3"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};

For(
     i=1,

     i <= NItems(NewNames),

     i++,

     dt = Data Table(OldNames[i]);

     dt << Set Name(NewNames[i])

);

 

jthi
Super User

Re: Data Table evaluation in For Loop from a list

You seem to be missing at least definition for i (i = 1), also I'm not sure what NNames is.

This should be working example:

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt = Open("$SAMPLE_DATA/Quality Control/Failures3Delimited.jmp");
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

OldNames = {"Big Class", "Failures3Delimited", "Semiconductor Capability"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};

For(i = 1, i <= N Items(OldNames), i++,
	dt = Data Table(OldNames[i]);
	dt << Set Name(NewNames[i])
);
-Jarmo
user8421
Level II

Re: Data Table evaluation in For Loop from a list

Sorry I realized I did miss the parts of my script while I was simplifying.

NNames = NItems(NewNames);
 and i=1 for the first argument in the For loop.

Even with both of those defined correctly in my script I still get the same error message

gzmorgan0
Super User (Alumni)

Re: Data Table evaluation in For Loop from a list

@user8421 ,

Did you successfully run @jthi's script?  If yes, then I suspect: 

  • one or more of the tables are closed
  • one or more of the tables are private
  • wrong old names.

Below is a slight modification to @jthi's script. I make the 3rd table private, and I add show statements to the For loop.

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt = Open("$SAMPLE_DATA/Quality Control/Failures3Delimited.jmp");
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp", "Private");
OldNames = {"Big Class", "Failures3Delimited", "Semiconductor Capability"};
NewNames = {"New Name 1", "New Name 2", "New Name 3"};


For(i = 1, i <= N Items(OldNames), i++,
    show(i, OldNames[i], NewNames[i]);
	dt = Data Table(OldNames[i]);
	dt << Set Name(NewNames[i]);
);

Here is the log output

 

/*:

i = 1;
OldNames[i] = "Big Class";
NewNames[i] = "New Name 1";
i = 2;
OldNames[i] = "Failures3Delimited";
NewNames[i] = "New Name 2";
i = 3;
OldNames[i] = "Semiconductor Capability";
NewNames[i] = "New Name 3";
Cannot locate data table in access or evaluation of 'Data Table' , Data Table/*###*/(OldNames[i])

at line 11 in Script.jsl

The JMP Scripting Guide states for private table that

  • Private tables are not counted when N Table() returns the number of open data tables.
  • Private tables cannot be made current with Current Data Table().

This made me think that a private table might not have the same functionality, might not have teh names stored in memory since it is not counted.

 

Good luck! 

user8421
Level II

Re: Data Table evaluation in For Loop from a list

Thanks a bunch.  It was an issue with one of the table names and one tables being a private table.

Recommended Articles