Subscribe Bookmark RSS Feed

How do I insert a column a new column in jmp with data from a different data table

jmper9

Community Member

Joined:

Feb 23, 2015

Newb to jmp here. I am trying to create a new column in my code data.jmp file called "Limits" by matching the Standard and Grade from the Table matrix.jmp  file. e.g. The first row is Standard A & Gade 100, so the column in limits should be filled with  1.

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Assuming you do not want to change your data structure, using JSL like:

NamesDefaultToHere(1);

dtM = DataTable("Table Matrix.jmp");

dtD = DataTable("Code Data.jmp");

standardVals = Column(dtM, "MATRIX") << GetValues;

For(r=1, r<=NRow(dtD), r++,

  standard = Column(dtD, "STANDARD")[r];

  grade = Column(dtD, "GRADE")[r];

  limit = Column(dtM, grade)[Loc(standardVals, standard)];

  Column(dtD, "LIMIT")[r] = limit;

);


will work.

To run it, do 'File>New>New Script', paste in the code, then do 'Edit> Run Script' (make sure both tables are open first).

1 REPLY
Solution

Assuming you do not want to change your data structure, using JSL like:

NamesDefaultToHere(1);

dtM = DataTable("Table Matrix.jmp");

dtD = DataTable("Code Data.jmp");

standardVals = Column(dtM, "MATRIX") << GetValues;

For(r=1, r<=NRow(dtD), r++,

  standard = Column(dtD, "STANDARD")[r];

  grade = Column(dtD, "GRADE")[r];

  limit = Column(dtM, grade)[Loc(standardVals, standard)];

  Column(dtD, "LIMIT")[r] = limit;

);


will work.

To run it, do 'File>New>New Script', paste in the code, then do 'Edit> Run Script' (make sure both tables are open first).