Subscribe Bookmark RSS Feed

Can I apply a formula in formula editor by a variable in another column,


Community Trekker


Jan 13, 2016

In my data table I have data over time for several different items (indicated by color names for this question). There are 125 time points and data for each color at each time point. I want to create a formula in a new column that will give me the slope of the data for each color listed under the name column. I can easily put a formula for slope in a new column but do not know how to apply that formula by the name.

I added the fit Y by X of the data below. Basically I just need a way to save the slopes of all those lines into a data table.



Super User


Feb 10, 2013

In Y by X if you used the "Group By" and then fit your lines you have a number of summary tables in your output.  Right click on the Parameter estimate table and select "Make Combined Data Table".  This will give you a table the parameter estimate output that includes each group.

Alternatively, if you use Fit Model with a By variable then you could broadcast (command key on a mac) the Save Columns>Prediction Formula and obtain a column in your original table with a formula for each group (color) item (it will be a big if then type formula).


Super User


Jun 23, 2011

karen@boulderstats​ is right, I would like to offer another option:

using the fit model platform, if color is used as a dummy variable and an interaction with the slope you practically get a separate prediction for each category. at this stage, you can save the prediction formula as follows:

dt = Open( "$SAMPLE_DATA/" );

obj = Fit Model(

    Y( :y ),

    Effects( :Drug, :x, :Drug * :x ),

    Personality( Standard Least Squares ),

    Emphasis( Minimal Report ),



obj << Prediction Formula;

10994_pred formula y.png


Super User


Jun 22, 2012

Here is my script that will pull off the slopes for each of the groupings and place it into an output table

Names Default To Here( 1 ); 

dt = Open( "$SAMPLE_DATA/Semiconductor" );


// Find the number of groupings, to allow for the stripping

// off of each slope from the Fit Y by X

Summarize( dt, ByGroup = By( :Site ) );


// Run the Fit Y by X(Bivariate)

Biv = Bivariate( Y( :NPN1 ), X( :PNP1 ), Group By( :Site ), fit line );


// Create a list to store the slopes in

SlopeList = {};


// Pass through the bivariate ouput scraping off the slopes

For( i = 2, i <= N Items( ByGroup ) * 4 - 2, i = i + 4,

       Insert Into(



                     Word( 4, Report( Biv )[Outline Box( i )][Text Box( 1 )] << get text, " *" ) ||

                     Word( 5, Report( Biv )[Outline Box( i )][Text Box( 1 )] << get text, " *" )




// Create a new table with the slopes

dt2=New Table("Slopes",New Column("Group",character,values(ByGroup)),

       New Column("Slope",values(SlopeList))