- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
JSL: Iterate through columns
Hi, I have 2 questions (very new to this!)
First, I have multple columns of like data, and I need to apply the same formula to all of them. For example, if I had to find the mean of each column, can I automate that through some sort of iteration?
Second, how do I go about saving an operation as a list and not as a new column? For exmaple, if I had the following operation creating a new column in my chart
dt << New Column( "Example", Numeric, Formula(Col Mean( :Height, :Age ) ) );
(Basically finding the mean height for each age), could I simply store this operation as a list that can be used in another operation, rather than a column on my chart?
Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL: Iterate through columns
The script below handles your first issue
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
colnames = dt << get column names( numeric,string );
meanlist = {};
For( i = 1, i <= N Items( colnames ), i++,
meanlist[i] = Col Mean( column(dt,colnames[i]) )
);
For the second issue, you could meet what you need by creating a character column and then create your 2 or more calculations, convert each of them into a character string, and then concatinate the values together, to place them into a List, convert the list to a string: Char(MyList)......which would end up looking like "{45, 34}";
Or lastly, you could save the list as an expression.
But as far as JMP automatically handling the results in analyses, it currently does not have that capability
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL: Iterate through columns
The script below handles your first issue
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
colnames = dt << get column names( numeric,string );
meanlist = {};
For( i = 1, i <= N Items( colnames ), i++,
meanlist[i] = Col Mean( column(dt,colnames[i]) )
);
For the second issue, you could meet what you need by creating a character column and then create your 2 or more calculations, convert each of them into a character string, and then concatinate the values together, to place them into a List, convert the list to a string: Char(MyList)......which would end up looking like "{45, 34}";
Or lastly, you could save the list as an expression.
But as far as JMP automatically handling the results in analyses, it currently does not have that capability