cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
mostarr
Level IV

Trying to access data values from a column one-by-one

Summarize(dt, IDs = by(:ID)); //this finds all the unique IDs in the data file, which we will need
For (i=0, i<=N Items(IDs), i++,
    ID = donorIDs[i];
);

the above doesn't work, and throws a

 

Subscript problem in access or evaluation of 'IDs[i]' , IDs[/*###*/i]

error.

 

I guess this gets down to some of the fundamentals about how JMP is different from languages like Python and Java, where indexing is common, and instead data are handled in a way that is intended for analysis, display, and manipulation rather than access, or something like that? Sorry if I don't make sense, I'm just trying to make sense of this issue.

 

What data type is IDs at this point in time? A column? Is column a data type? Is this listed in the Scripting Index? I've looked there multiple times by now, maybe I just missed it? As someone with computer experience, it is very convenient to think in data and object types and I don't know how to deal with stuff in JMP that is so ambiguous.

 

So I guess the bottom line is, how do you perform an element-wise operation over a column in general?

1 REPLY 1
txnelson
Super User

Re: Trying to access data values from a column one-by-one

Summarize(dt, IDs = by(:ID));

The Summarize() function returns JMP Lists.  Therefore, IDs returns the unique values of the column ID from the data table referenced by the variable dt.

Proper referencing would be:

IDs[index value]

Therefore, referencing it in a For Loop would be:

For( i = 1, i <= N Items( IDs ), i++,
     variableX = IDs[i];
);

I did not use the variable name of ID as you used in your example.  While ID would be a fine name, it might be confusing, since you have a column of the same name in the data table referenced by variable dt.

Jim