Choose Language Hide Translation Bar
Highlighted
lwx228
Level VII

How can data in memory array be read and modified with JSL?

Hello, everyone!

For example, this code, reading the data into "copydt", and how to use JSL to read the "KATIE" in "copydt" in one step, I used two steps in the code.

dt = Open("$SAMPLE_DATA\Big class.jmp");Wait(0);
copydt = dt[0,0]; 
dt[0,0] = .; 
a=copydt[1,1];
b=a[1,1];
c={copydt[1,1][1,1]};

dt[0,0] = copydt;Wait(0);


In addition, how to modify the data in "copydt" directly with JSL?

For example, change the name of the first row to "KATIE2" and change the age of the first row to 18.

Writes the modified data to the original data table.

 

Thanks!

2019-10-20_19-17.png

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How can data in memory array be read and modified with JSL?

To answer the question raised in the subject of this discussion, use subscripts on the variable holding the data formed from the data table. You can use the debugger or the log to examine the results as you proceed through your example. I will use the log.

 

 

dt = Open("$SAMPLE_DATA\Big class.jmp");
copydt = dt[0,0];

 

The subscripting used in dt[0,0] references all rows and all columns - the entire table. The variable copydt contains a list of lists. Each sub-list is a row in the original data table.

 

 

dt[0,0] = .;

 

The assignment of missing occurs for all rows and all columns - the entire table. The data table now contains 40 rows of missing values for 5 data columns.

 

 

a = copydt[1,1];

 

This expression uses standard list subscripts. You are retrieving the first item in the list. The value is a list representing the first row in the original data table. When you learn how to subscript lists, then you know that this expression is asking for the same thing twice - the first element. All of the following expressions are identical.

 

a = copydt[1];
a = copydt[1,1];
a = copydt[1,1,1];

So the first form is more concise and preferred.

 

b = a[1,1];

 

Same as the previous expression. You are retrieving the first item in the list. The value is a character string from the first column in the first row in the original data table.

 

c = { copydt[1,1][1,1] };  // c = { copydt[1][1] } is equivalent, sufficient, and preferred

 

You have assigned a one-element list to a variable. No evaluation of the list item occurred.

 

dt[0,0] = copydt;

 

You assigned the list of lists to the entire data table. Each sub-list becomes a new row in the data table. This step demonstrates the symmeteric behavior between the second line and the last line.

 

To answer the questions raised in the body of the discussion, you use subscripts:

 

copydt[1][1] = "Katie2";
copydt[1][2] = 18;

 

The subscripts are nested. So read copydt[1][1] = "Katie2" as assign "Katie2" to the first item inside the first item. Read copydt[1][2] = 18 as assign 18 to the second item inside the first item.

 

Note that the ability to shuffle data between the data table, matricx, and list data structures changes with each version of JMP. In general, the capabilities increase and the differences between the structures decrease.

 

So, I have explained what you did but I have no idea why you did it or what you want to accomplish. Your subject is very broad and vague. What do you want to do?

 

Select Help > Books > Scripting Guide in JMP for more complete information and explanations of data tables, lists, and matrices.

Learn it once, use it forever!

View solution in original post

1 REPLY 1
Highlighted

Re: How can data in memory array be read and modified with JSL?

To answer the question raised in the subject of this discussion, use subscripts on the variable holding the data formed from the data table. You can use the debugger or the log to examine the results as you proceed through your example. I will use the log.

 

 

dt = Open("$SAMPLE_DATA\Big class.jmp");
copydt = dt[0,0];

 

The subscripting used in dt[0,0] references all rows and all columns - the entire table. The variable copydt contains a list of lists. Each sub-list is a row in the original data table.

 

 

dt[0,0] = .;

 

The assignment of missing occurs for all rows and all columns - the entire table. The data table now contains 40 rows of missing values for 5 data columns.

 

 

a = copydt[1,1];

 

This expression uses standard list subscripts. You are retrieving the first item in the list. The value is a list representing the first row in the original data table. When you learn how to subscript lists, then you know that this expression is asking for the same thing twice - the first element. All of the following expressions are identical.

 

a = copydt[1];
a = copydt[1,1];
a = copydt[1,1,1];

So the first form is more concise and preferred.

 

b = a[1,1];

 

Same as the previous expression. You are retrieving the first item in the list. The value is a character string from the first column in the first row in the original data table.

 

c = { copydt[1,1][1,1] };  // c = { copydt[1][1] } is equivalent, sufficient, and preferred

 

You have assigned a one-element list to a variable. No evaluation of the list item occurred.

 

dt[0,0] = copydt;

 

You assigned the list of lists to the entire data table. Each sub-list becomes a new row in the data table. This step demonstrates the symmeteric behavior between the second line and the last line.

 

To answer the questions raised in the body of the discussion, you use subscripts:

 

copydt[1][1] = "Katie2";
copydt[1][2] = 18;

 

The subscripts are nested. So read copydt[1][1] = "Katie2" as assign "Katie2" to the first item inside the first item. Read copydt[1][2] = 18 as assign 18 to the second item inside the first item.

 

Note that the ability to shuffle data between the data table, matricx, and list data structures changes with each version of JMP. In general, the capabilities increase and the differences between the structures decrease.

 

So, I have explained what you did but I have no idea why you did it or what you want to accomplish. Your subject is very broad and vague. What do you want to do?

 

Select Help > Books > Scripting Guide in JMP for more complete information and explanations of data tables, lists, and matrices.

Learn it once, use it forever!

View solution in original post

Article Labels

    There are no labels assigned to this post.