turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- BI
- /
- Visual Analytics
- /
- Using Graph Builder with Variable Column name

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-10-2015 04:10 AM

Hi,

Sample Data Table:

My script is like this,

**tt = Graph Builder(**

** Show Control Panel( 0 ),**

** Variables(**

** X( :HDDT ),**

** Y( :Yield, Side( "Right" ) ),**

** Y( :CAEF, Position( 1 ) ),**

** Y( :CAHD, Position( 1 ) )**

** ),**

** Elements(**

** Bar(**

** X,**

** Y( 2 ),**

** Y( 3 ),**

** Y( 4 ),**

** **

**Legend( 1 ),**

** Jitter( 1 )**

** ),**

** Points( X, Y( 1 ), Legend( 2 ), Jitter( 1 ) )**

** )**

** )**

But then, only Column "HDDT" and "Yield" is the fixed name for every data I will gather. Columns with "CA**" will change every batch of data.

So I want to create a script that these columns of "CA**" will be variable.

Currently, I create a script like this,

**For (i=3,i<=ncols,i++,**

**tt = Graph Builder(**

** Show Control Panel( 0 ),**

** Variables(**

** X( :HDDT ),**

** Y( :Yield, Side( "Right" ) ),**

** Y( :Column(i),Position( 1 ))**

** ),**

** Elements(**

** Points(**

** X,**

** Y( i ),**

** Legend( 1 ),**

** Jitter( 1 )**

** ),**

** Points( X, Y( 1 ), Legend( 2 ), Jitter( 1 ) )**

** )**

** )**

But the result, instead of 1 graph will appear, each "Y variable" is coming out.

Is there a best way? Thank you for the help. ^_^

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-10-2015 09:38 AM

Hi there! I moved your question to the SAS Visual Analytics community, where experts there are more likely to be able to help.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-10-2015 10:31 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-10-2015 10:35 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-10-2015 10:50 AM

Happy to help...

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-10-2015 04:27 PM

I'll answer here, but note there is a separate JMP Community where more JMP experts will see your questions.

Yes, your script is launching Graph Builder 3 times. You need to somehow construct a single script which accounts for the variable number of columns and then run that script. JSL supports that kind of meta-programming (a script that creates another script) using the functions Expr(), Name Expr() and Eval Expr().

Below is an example like what I think you are trying to do.

// a table with lots of columns

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

// an expression for the graph's variables

vars = Expr( Variables( X( :Country ), Y( :Score, Side( "Right" ) ) ) );

// an expression for Points elements

points = Expr( Points( X, Jitter( 1 ) ) );

// a loop to programmitically insert variables into those expressions

first col = 4;

last col = 6;

For( i = first col, i <= last col, i++,

Insert Into( vars, Eval Expr( Y( Expr( Column( dt, i ) ), Position( 1 ) ) ) );

Insert Into( points, Eval Expr( Y( Expr( i - first col + 2 ) ) ), 1 + i - first col );

);

//Show( vars, points );

// build the Graph Builder expression from those

gb = Eval Expr(

Graph Builder(

Show Control Panel( 0 ),

Expr( Name Expr( vars ) ),

Elements( Expr( Name Expr( points ) ), Line( X, Y( 1 ) ) )

)

);

//show( gb );

gb; // execute the expression