Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Re: Looping Through Columns [Range Check]

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Looping Through Columns [Range Check]

Mar 28, 2019 11:40 AM
(719 views)

I would like some guidance applying a range check based on already populated spec limits.

This one test has 87 screening limits and I would like to apply a range check in order to assist in establishing spec limits.

I know i can use the script for what i want to accomplish but i can't figure out how to apply the Range Check( LELE( 16, 46 ) ), for example..

Thank you for your time

```
// dtsplitmeas is the table that is split
cols = dtsplitmeas << get Column names( string );
// dtlim is _SPEC LIMITS_ .jmp attached to this thread
// dtrange is _RANGE CHECK_ .jmp attached to this thread
// Assign Spec Limit script
For( i = 1, i <= N Cols( dtsplitmeas ), i++,
limrow = Try( (dtlim << get rows where( dtlim:SPEC_COL_NAMES == cols[i] ))[1], . );
If( Is Missing( limRow ) == 0,
specs = {LSL( . ), USL( . ), Target( . ), Show Limits( 1 )};
specs["LSL"] = dtlim:LSL[limrow];
specs["USL"] = dtlim:USL[limrow];
Column( dtsplitmeas, Char( cols[i] ) ) << set property( "spec limits", Eval( specs ) );
);
);
```

7 REPLIES 7

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Looping Through Columns [Range Check]

This works for me. I changed the try to just a check that it has rows in case that would fail for any reason, I wouldn't want to silently just pass errors.

```
Names default to here(1);
dtsplitmeas = Data Table("sample data");
dtlim = Data Table("_ SPEC LIMITS_");
dtrange = Data Table( "_ RANGE CHECK_" );
// dtsplitmeas is the table that is split
cols = dtsplitmeas << get Column names( string );
// dtlim is _SPEC LIMITS_ .jmp attached to this thread
// dtrange is _RANGE CHECK_ .jmp attached to this thread
// Assign Spec Limit script
For( i = 1, i <= N Cols( dtsplitmeas ), i++,
limrow = dtlim << get rows where( dtlim:SPEC_COL_NAMES == cols[i] );
If( nrows(limrow),
specs = {LSL( . ), USL( . ), Target( . ), Show Limits( 1 )};
specs["LSL"] = dtlim:LSL[limrow[1]];
specs["USL"] = dtlim:USL[limrow[1]];
Column( dtsplitmeas, Char( cols[i] ) ) << set property( "spec limits", Eval( specs ) );
//this assumes that the spec_col_names are exactly the same in both tables
Eval(EvalExpr(
Column( dtsplitmeas, char(cols[i])) << Set Property("Range Check",
LELE(Expr(dtrange:rangeA[limrow[1]]), Expr(dtrange:rangeB[limrow[1]]))
)
));
);
);
```

Vince Faller - Predictum

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Looping Through Columns [Range Check]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Looping Through Columns [Range Check]

Here is one example on how to do it:

```
Names Default To Here( 1 );
dtsplitmeas = Data Table( "sample data" );
dtrange = Data Table( "_ RANGE CHECK_" );
// dtsplitmeas is the table that is split
cols = dtsplitmeas << get Column names( string );
// dtlim is _SPEC LIMITS_ .jmp attached to this thread
// dtrange is _RANGE CHECK_ .jmp attached to this thread
// Assign Spec Limit script
For( i = 1, i <= N Cols( dtsplitmeas ), i++,
rangerow = Try( (dtrange << get rows where( dtrange:SPEC_COL_NAMES == cols[i] ))[1], . );
If( Is Missing( rangeRow ) == 0,
Eval(
Substitute(
Expr(
Column( dtsplitmeas, Char( cols[i] ) ) <<
Range Check( LELE( __low__, __high__ ) )
),
Expr( __low__ ), dtrange:rangeA[rangerow],
Expr( __high__ ), dtrange:rangeB[rangerow]
)
)
);
);
```

Jim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Looping Through Columns [Range Check]

Very much appreciated. I will try it ASAP..

D.

D.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Looping Through Columns [Range Check]

Again, thank you both for your help. However, I am getting this error "Out of range data for column 'RF_IN_4_LPF_THRU to BM_A_OUT S21 State 1 @ 10.25GHz' will be set to missing. Continue?

I remember seeing this pop up when i manually set the range... Did this happen when you ran it on your side?

Note: I am still getting the error...

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Looping Through Columns [Range Check]

Awhile back you provided me with a great scrip that itterates differnt columns, create a journal, graph plots and then appends that journal..

I am looking to do the same thing with Control Charts however, 87 different expressions for a Yaxis could be done but i am wondering if you can apply the same concept with the limits and range check? Our tests are getting more elaborate and in the case of this original post, I have 504 screening conditions. 87 actaul test outputs with 417 calculated outputs.

Thanks in advance

```
doDistrPlot = Function(
{dtsplitmeas, Yaxis },
Eval(
Substitute(
Expr(
gb = Control Chart Builder(
Size( 734, 854 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables(
Y( Eval( Yaxis )) // Is evaluated in the same manner as the limits and range check.
),
Chart( Position( 1 ), Limits( Sigma( "Moving Range" ) ) ),
Chart( Position( 2 ), Limits( Sigma( "Moving Range" ) ) )
)
)
)
);
(gb << Top Report )[Text Box( 1 )] << Delete;
Report( gb )[Outline Box( 1 )] << Set Title( Eval Insert( Yaxis ) );
);
cols = dtsplitmeas << get Column names( string );
jjr1 = New Window( "Journal Window", << Journal );
For( i = 1, i <= N Cols( dtsplitmeas ), i++,
Yaxis = dtlim << Get Rows Where( dtlim:SPEC_COL_NAMES == cols[i] );
doDistrPlot( dtsplitmeas, Yaxis );
jjr1 << Append( Report( gb ) );
gb << Close Window;
);
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Looping Through Columns [Range Check]

If you run your function for just one value of Yaxis, does it give you your desired control chart? I suspect that it does not. You have an Eval(Substitute(Expr())) instance, that does not appear that it should work, since it does not have any substitution elements specified.

You need to take the baby steps to get the function to run, and then start to add in the looping.

But first, I think you need to spend a good deal of time reading the Scripting Guide

Help==>Books==>Scripting Guide

Jim