Subscribe Bookmark RSS Feed

How to use chosen columns (using dialog) later in the script

sami_hokkanen

New Contributor

Joined:

Aug 30, 2016

Hi,

I would like to make dialog with preselected column name which you can change or choose some other if they are not in dataset. The problem is that I am not able to use these chosen ones later.

So here is my code:

Clear Globals();

dt = Current Data Table();

If( Is Empty( dt ),

    dt = Open()

);

col_name_list = dt << get column names( string );

Show( col_name_list );

dialogADMI = Empty();

If( Contains( col_name_list, "ADJMI Rev2" ),

    dialogADMI = Column( "ADJMI Rev2" )

);

dialogMIPLdraw1 = Empty();

If( Contains( col_name_list, "MIPLdraw1" ),

    dialogMIPLdraw1 = Column( "MIPLdraw1" )

);

dlg = Column Dialog(

  ADMI2 = Col List( "ADJMI Rev2",

       Min Col( 1 ),

       Max Col( 1 ),

  Columns( dialogADMI )

  ),

  MIPLdraw1Col = Col List( "MIPLdraw1",

       Min Col( 1 ),

       Max Col( 1 ),

  Columns( dialogMIPLdraw1 )

  ),

);


Show( dlg["Button"] );

If( dlg["Button"] == -1,

  Throw()

);

Remove From( dlg );

Eval List( dlg );

ADMI2 = ADMI2[1] << get name;

MIPLdraw1Col = MIPLdraw1Col[1] << get name;


// Until here I think everything is fine

// But next sted does not work

dt <<

  Select Where(:MIPLdraw1Col != "") <<

  Subset(

  columns (:Patient, :ADMI2, :MIPLdraw1Col),

  Output Table Name("Draw1"),

  );

;

// So I try to Select those with has not empy in MIdraw1Col

// And I got this: dt << Select Where( :MIPLdraw1Col/*###*/ != "" ) <<

// This works if  use the original name of the column MIPLdraw1 but I want to have the possibility to use some other column name

// So how should I do it?



2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

You may need Column variables instead of their Names.

Try exchange the last part of your cod with this:

ADMI2 = Column(ADMI2[1] << get name);

MIPLdraw1Col = Column(MIPLdraw1Col[1] << get name);

// Until here I think everything is fine

// But next sted does not work

dt << Select Where(MIPLdraw1Col[] != "") << Subset(

    columns(:Patient, ADMI2, MIPLdraw1Col),

    Output Table Name("Draw1")

);

txnelson

Super User

Joined:

Jun 22, 2012

The issue you are having is that you are telling JMP that you have a columns named :ADMI2 and :MIPLdraw1Col.  This is because you are using the scoping element of ":" in front of the references.  You do not have columns of these names.  You have memory variables whose values have the names of columns.  If you change the code to the below, it will work:

dt << Select Where( As Column( MIPLdraw1Col ) != "" ) << Subset(

       columns( :Patient, Column( ADMI2 ), Column( MIPLdraw1Col ) ),

       Output Table Name( "Draw1" ),

);

Jim