- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Create a New Column and Add Notes
I find the Notes property in a JMP column useful as a means to automatically add labels to the resulting graphs. The issue I'm having relates to generating new data columns related to parent columns and having the parent Notes automatically apply across. In the script below, I had hoped that the line
<< set property( "Notes", Notes );
would do the trick but I'm missing something. Here's the main script.
Names Default To Here( 1 );
dt = Current Data Table();
colList = dt << get column names( numeric, string );
foundCols = "";
For( i = 1, i <= N Col( dt ), i++,
Spud = ":" || colList[i];
Spuds = Parse( Eval Insert( Spud ) );
Show(Spuds);
spec = Column( dt, colList[i] ) << get property( "Spec Limits" );
Notes = Column( dt, colList[i] ) << get property( "Notes" );
Show(Notes);
dt << clear select;
If( Is Empty( spec ) == 0,
dt << New Column(
(Column( dt, colList[i] ) << get name) || " % Delta From Target",
Formula(
If( Spuds > (Spuds << get property( "Spec Limits" ))["Target"],
Num(
(Spuds - (Spuds << get property( "Spec Limits" ))["Target"])
/ ((Spuds << get property( "Spec Limits" ))["USL"] - (Spuds
<< get property( "Spec Limits" ))["Target"])
) * 100,
If( Spuds < (Spuds << get property( "Spec Limits" ))["Target"],
Num(
((Spuds << get property( "Spec Limits" ))["Target"]
-Spuds) / ((Spuds << get property( "Spec Limits" ))[
"LSL"] - (Spuds << get property( "Spec Limits" ))[
"Target"]) * 100
),
0
)
)
)
) << set property( "Notes", Notes );
If( Is Missing( Try( spec["LSL"], . ) ) == 0,
dt << select where( As Column( dt, colList[i] ) + spec["LSL"] );
Try( Column( dt, N Cols( dt ) )[dt << get selected rows] = 0 );
);
If( Is Missing( Try( spec["USL"], . ) ) == 0,
dt << select where(
As Column( dt, colList[i] ) - spec["USL"],
current selection( "extend" )
);
Try( Column( dt, N Cols( dt ) )[dt << get selected rows] = 0 );
);
dt << select where(
Is Missing( As Column( dt, colList[i] ) ),
current selection( "extend" )
);
dt << invert row selection;
Try( Column( dt, N Cols( dt ) )[dt << get selected rows] = 1 );
Column( dt, N Cols( dt ) );
If( foundCols == "",
foundCols = ":Name(\!"" || (Column( dt, colList[i] ) << get name) ||
" % Delta From Target\!")",
foundCols = foundCols || ", " || ":Name(\!"" || (
Column( dt, colList[i] ) << get name) || " % Delta From Target\!")"
);
);
);
Any help appreciated
Slán
SpannerHead
Slán
SpannerHead
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Create a New Column and Add Notes
Either separate the note setting to happen after new column
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
For Each({colname}, dt << Get Column Names("String"),
curnote = Column(dt, colname) << Get Property("Notes");
new_col = dt << New Column("A", Character, Nominal);
new_col << Set Property("Notes", curnote);
);
or move it inside new column
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
For Each({colname}, dt << Get Column Names("String"),
curnote = Column(dt, colname) << Get Property("Notes");
new_col = dt << New Column("A", Character, Nominal, Set Property("Notes", curnote));
);
You can get idea for the script by selecting a column with a note property, click the header with right click and select Copy Copy Columns or you can create new column and adding the property immediately and get the script from enhanced log
Data Table("Big Class") << New Column("Column 6",
Numeric,
"Continuous",
Format("Best", 12),
Set Property("Notes", "asdasd")
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Create a New Column and Add Notes
Either separate the note setting to happen after new column
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
For Each({colname}, dt << Get Column Names("String"),
curnote = Column(dt, colname) << Get Property("Notes");
new_col = dt << New Column("A", Character, Nominal);
new_col << Set Property("Notes", curnote);
);
or move it inside new column
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
For Each({colname}, dt << Get Column Names("String"),
curnote = Column(dt, colname) << Get Property("Notes");
new_col = dt << New Column("A", Character, Nominal, Set Property("Notes", curnote));
);
You can get idea for the script by selecting a column with a note property, click the header with right click and select Copy Copy Columns or you can create new column and adding the property immediately and get the script from enhanced log
Data Table("Big Class") << New Column("Column 6",
Numeric,
"Continuous",
Format("Best", 12),
Set Property("Notes", "asdasd")
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Create a New Column and Add Notes
Jarmo
Went with the second one, works spot on!
Thanks
Slán
SpannerHead
Slán
SpannerHead