Help extracting name of variable transformed on the flyHi all,
I need help with a seemingly simple problem but for which I cannot find a solution. I have written a JSL code to do some computation and the first things it does is open a Column Dialog window where one can choose table columns and put them into different roles (in my case X and Y variables). What I need to do is to get the names of these table columns so that I can use them later on to show the axis names (using the Yname and Xname functions) in a Graph box . All is fine when the table columns are directly used. However, if I do a transformation on the fly by right-clicking the variable before assigning to a role in the Column Dialog window, then things get more complicated. Normally, I would use something like:
yn= as column(eval( cdw["yv"])) << Get Name;
where cdw in the object return by the column dialog window. However, in the case of a transformed variable, it will produce
yn = deleted object reference[];
If I break down the problem, the eval( cdw["yv"])) would yield a one element list looking like:
{Transform Column("Log10[Name of Table colum]",Formula( Log10( :Name( "Name of Table colum" ) ) ))}
How can I extract from that just the portion Log10[Name of Table colum] so that I can use it in a Yname or Xname statement in a Graph Box??
Many thanks for any help you can provide.
Regards, Yves
Re: Help extracting name of variable transformed on the flyYou are correct, I thought the [1] was because there was more than one variable selected in that role. Apologies for not testing your solution more thoroughly before replying!
Many many thanks, Yves
Re: Help extracting name of variable transformed on the flyI think you must be doing something different. Here's my log after running the code I posted.
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
cd=Column Dialog(
ex y = ColList( "Y", Min Col( 1 ), Max Col( 2 ), Data Type( "Numeric" ) ),
ex x = ColList( "X",
Max Col( 1 ),
Modeling Type( {"Continuous", "Multiple Response"} )
),
Line Up( 2,
Text Box( "Alpha" ), ex = EditNumber( .05 ),
Text Box( "Beta" ), ey = EditText( "xyz" )
),
HList( cb = Check Box( "check", 1 ) ),
HList( combo = Combo Box( "option1", "option2" ) ),
HList( rb = RadioButtons( "a", "b" ) )
);
show(cd["ex y"], arg(cd["ex y"][1], 1));
/*:
//cd["ex y"] = {Transform Column("Birth Year^3", Formula(:Birth Year ^ 3))};
//Arg(cd["ex y"][1], 1) = "Birth Year^3";Re: Help extracting name of variable transformed on the flyThanks Jeff but it doesn't appear to work either (I feel slightly less stupid now that 2 experts have offered advice and have gotten to the same point as I!). Again the arg() will return the whole thing:
Transform Column("Age Group^3", Formula(:Age Group ^ 3))I would like to be able to use only
Age Group^3
Yves
Re: Help extracting name of variable transformed on the flyThe arg() function will get you there.
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
cd=Column Dialog(
ex y = ColList( "Y", Min Col( 1 ), Max Col( 2 ), Data Type( "Numeric" ) ),
ex x = ColList( "X",
Max Col( 1 ),
Modeling Type( {"Continuous", "Multiple Response"} )
),
Line Up( 2,
Text Box( "Alpha" ), ex = EditNumber( .05 ),
Text Box( "Beta" ), ey = EditText( "xyz" )
),
HList( cb = Check Box( "check", 1 ) ),
HList( combo = Combo Box( "option1", "option2" ) ),
HList( rb = RadioButtons( "a", "b" ) )
);
foo=arg(cd["ex y"][1], 1);Re: Help extracting name of variable transformed on the flyThanks Jim for your quick reply but this won't really work because it will use the whole thing, i.e.
Transform Column("Age Group^3", Formula(:Age Group ^ 3)) as the axis name. This is rather cumbersome in a graph. So I am trying to extract only the
Age Group^3
part as the axis name.
Thanks again, Yves
Re: Help extracting name of variable transformed on the flyTaken from the Scripting Index for Col Dialog
Help==>Scripting Index.........search on Col Dialog
Here is the example Script
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
xx = Column Dialog(
ex y = ColList( "Y", Min Col( 1 ), Max Col( 2 ), Data Type( "Numeric" ) ),
ex x = ColList( "X",
Max Col( 1 ),
Modeling Type( {"Continuous", "Multiple Response"} )
),
Line Up( 2,
Text Box( "Alpha" ), ex = EditNumber( .05 ),
Text Box( "Beta" ), ey = EditText( "xyz" )
),
HList( cb = Check Box( "check", 1 ) ),
HList( combo = Combo Box( "option1", "option2" ) ),
HList( rb = RadioButtons( "a", "b" ) )
);
show( xx );
I have added a reference to the Col Dialog Box() itself. If you run this, and create a Transform variable in the Col Dialog Box, it will show that a list called "xx" contains the information you need.
xx = {ex y = {Transform Column("Age Group^3", Formula(:Age Group ^ 3))}, ex x = {}, Text Box, ex = 0.05, Text Box, ey = "xyz", cb = 1, combo = 1, rb = 1, Button(1)};
You can get this information by extracting from the ex y list from within the xx list