Hi @marc1,
I believe there's a straightforward way to do this without involving any scripting. Let's start with Table A and Table B (attached) that resemble your situation. ![tablea.png tablea.png](https://community.jmp.com/t5/image/serverpage/image-id/20181i26FE38AECDB7D4DD/image-size/medium?v=v2&px=400)
![tableb.png tableb.png](https://community.jmp.com/t5/image/serverpage/image-id/20182i1A5FC7B31D7FF6DE/image-size/medium?v=v2&px=400)
What we're going to need is a table like the following to join with Table A:![split.png split.png](https://community.jmp.com/t5/image/serverpage/image-id/20183i005D6D62959F46B7/image-size/large?v=v2&px=999)
So how do we get there? What we'll be doing is using Tables > Split on Table B, using a version of the Code column as the Split By column, and using a Column of 1s as the Split Column. First, we need to make a version of the Code column that has "Code: " as text in the beginning (this will keep clear the column names we end up making, but isn't strictly necessary). Here's some JSL to add such a column to your table:
New Column("Code Text", Character, "Nominal", Formula("Code " || Char(:Code)));
This uses a column formula to prepend "Code: " to each code value. Now, we need a column that will be the values in the final table. I'll make a column called "Present" and set the values to all ones:
New Column("Present", Numeric, "Continuous", Format("Best", 12), Formula(1));
Table B looks like this now:
Next, we "Split" this table to get it into a wide format with one row per ID. We'll use Tables > Split, and use :Code Text as the Split By column, :Present as the Split Columns, and :ID as the Group column. If you're using a Formula column (as I did) for the Split Column, be sure to uncheck "Copy Formula."![split dialog.png split dialog.png](https://community.jmp.com/t5/image/serverpage/image-id/20190i80A116BF080274EB/image-size/large?v=v2&px=999)
This returns: ![st.png st.png](https://community.jmp.com/t5/image/serverpage/image-id/20191i9721975F87B50BEA/image-size/large?v=v2&px=999)
Which is nearly there -- we have blanks where the code was not present, so we need to replace those with 0s. We can do this by selecting all the Code columns, then using Cols > Standardize Attributes. Then, click Recode at the top, and change . to 0. Another option, which I find to be very fast and perfectly adequate here is using a simple Find and Replace -- Edit > Search > Find: Use nothing as the "find what" and 0 as the replace with, and check "Match entire cell value." Click Replace All, and you're done.![find replacew.png find replacew.png](https://community.jmp.com/t5/image/serverpage/image-id/20192i016957ACFA0A5FFE/image-size/large?v=v2&px=999)
Now we have a table with the IDs, and the presence or absence of the codes. The last thing to do is bring those values into Table A. We can use Tables > Join, or Tables > Update. I'll use Tables > Update here: ![update.png update.png](https://community.jmp.com/t5/image/serverpage/image-id/20193iDEA003DB1B328569/image-size/large?v=v2&px=999)
And there we go!![final.png final.png](https://community.jmp.com/t5/image/serverpage/image-id/20194iC087C4DBD4A3D571/image-size/large?v=v2&px=999)
Including the missing values for IDs I and J that I did not have in the Codes table (which means this method is good for noticing when you don't have data for certain items). I hope this helps get you started in your situation.
@julian