Subscribe Bookmark RSS Feed

How to refer to a column with unknown name

kofi

Community Trekker

Joined:

Sep 18, 2013

Can anybody tell me how to send a column name (that I don't know beforehand and that will be determined while running the script) to a graph report, eg:

variable1 = "Metal";

name1 = "Width of " || variable1;

Overlay Plot(

    X( : Price ),

    Y(        : (Column (name1))  ),

This works to change line color:

    : Name ("Width of Metal") (Connect Color( 19 )

But I don't know the column name, because it depends on variable1. Therefore, I need to replace the expression  Name ("Width of Metal") and use the variable name1. I've tried

: Name (name1), : Column (name1), :name1      etc etc etc etc etc. Nothing works. But surely there's a way to incorporate a variable into the column name for the SendTo Command?

Regards,
Kofi

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Here is the method I use:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/big class.jmp" );

variable1 = "ght";

name1 = "Wei" || variable1;

Eval(

      Substitute(

                  Expr( Overlay Plot(

                   X( :height ),

                   Y( __var__ ),

                    Separate Axes( 1 ),

                    Connect Thru Missing( 1 ),

                    __var__( Connect Color( 19 ), Overlay Marker( 8 ) ),

                    SendToReport(

                    Dispatch(

                    {},

                                     "Overlay Plot Graph",

                    FrameBox,

                    {DispatchSeg( Line Seg( 1 ), {Line Color( "Medium Dark Red" )} )}

                    )

                 )

              )

         ),

            Expr( __var__ ), Parse( ":" || name1 )

      )

);

Jim
5 REPLIES
pmroz

Super User

Joined:

Jun 23, 2011

Overlay Plot(

    X( : Price ),

    Y( eval(name1) ),

);

ron_horne

Super User

Joined:

Jun 23, 2011

try this:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

variable1 = "ght";

name1 = "hei" || variable1;

Overlay Plot( X( :weight ), Y( Eval( name1 ) ) );

best,

ron

kofi

Community Trekker

Joined:

Sep 18, 2013

Hi guys,

thanks for reply. But the problem is not how to chose the column to create the overlay plot, but how to refer to the column to change the line colour etc in the graph.

: how_do_I_refer_here_to_the_column_in_order_to_change (Connect Color( 20 ), Overlay Marker Color( 20 ),  Overlay Marker( 20 )),


All the following option I've tried and they don't work:

: name1

: (name1)

: Column (name1)

: (Column (name1))

: eval (name1)

etc

: Column (1)  or : (Column (1))   doesn't work either, by the way.

Cheers,
Kofi

Solution

Here is the method I use:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/big class.jmp" );

variable1 = "ght";

name1 = "Wei" || variable1;

Eval(

      Substitute(

                  Expr( Overlay Plot(

                   X( :height ),

                   Y( __var__ ),

                    Separate Axes( 1 ),

                    Connect Thru Missing( 1 ),

                    __var__( Connect Color( 19 ), Overlay Marker( 8 ) ),

                    SendToReport(

                    Dispatch(

                    {},

                                     "Overlay Plot Graph",

                    FrameBox,

                    {DispatchSeg( Line Seg( 1 ), {Line Color( "Medium Dark Red" )} )}

                    )

                 )

              )

         ),

            Expr( __var__ ), Parse( ":" || name1 )

      )

);

Jim
kofi

Community Trekker

Joined:

Sep 18, 2013

Thanks Jim,

this does the job. Great!

Cheers,

Kofi