cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
shaira
Level IV

Column referencing: What is the difference between Column("Example") and :Name("Example")?

Dear all,

By googling examples, I kinda get the hang of when to use Column("Example") and :Name("Example"). When used in summary table and equality conditions, I use :Name("Example"). Meanwhile, I use Column("Example") when changing column properties.

 

However, I still fail to understand the difference between the two, concept-wise. Can anyone give insights to help me understand the difference between the two?

 

Thank you,

Shaira

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Column referencing: What is the difference between Column("Example") and :Name("E

I believe, too, that Name() is not a JSL function but a directive to the JSL interpreter. It is meant to help the interpreter handle improper names when a user saves a script. (For example, click the red triangle at the top of a platform and select Save Script > To Data Table.) On the other hand, the Column() function is intended for us to obtain a valid column reference given a column index or proper name and optionally a data table reference.

I don't use the Name() directive in my scripts. That practice is a matter of personal choice and scripting style.

View solution in original post

7 REPLIES 7
Byron_JMP
Staff

Re: Column referencing: What is the difference between Column("Example") and :Name("E

There are lots of ways to reference a column. For Example:

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
a = Column( 4 )[1] + Column( 4 )[2];
b = Column( 4 )[1] + :name( "height" )[2];
c = Column( 4 )[1] + Column( "height" )[2];
d = Column( 4 )[1] + :height[2];
Show( a, b, c, d );

:Age << Color Cells( "Red" );
Column( 4 ) << Color Cells( "blue" );
:name( "weight" ) << Color Cells( "green" );

:height << Set Property( "Units", inches );
column(5)<< set property( "Units", lbs);
:name("weight")<<get property ("Units");

Distribution(Continuous Distribution( Column( :height )));
Distribution(Continuous Distribution( Column( :name("weight") )));
Distribution(Continuous Distribution( Column( 5 )));
Distribution(Continuous Distribution( Column( "height" )));


how you reference a column depends on what you are trying to do, and what's convenient.

JMP Systems Engineer, Health and Life Sciences (Pharma)

Re: Column referencing: What is the difference between Column("Example") and :Name("E

I believe, too, that Name() is not a JSL function but a directive to the JSL interpreter. It is meant to help the interpreter handle improper names when a user saves a script. (For example, click the red triangle at the top of a platform and select Save Script > To Data Table.) On the other hand, the Column() function is intended for us to obtain a valid column reference given a column index or proper name and optionally a data table reference.

I don't use the Name() directive in my scripts. That practice is a matter of personal choice and scripting style.

pmroz
Super User

Re: Column referencing: What is the difference between Column("Example") and :Name("E

One other wrinkle to keep in mind.  Sometimes column("Column Name") doesn't work.  Instead you have to say AS Column("Column Name"). I've had to use this reference method for get rows where and with new column formulas. For example:

 

match_rows = rts_signal_detail_report_dt << get rows where(as column(rts_signal_detail_report_dt, one_col) == "Y");


xl_dt << new column("TMP_AER#VER", character, nominal, 
 formula(as column(xl_col1) || "#" || char(as column(xl_col2))));

I found this out by trial and error.  I.e. it didn't work using the regular column() reference, so I tried AS Column and it worked.

shaira
Level IV

Re: Column referencing: What is the difference between Column("Example") and :Name("E

Thank you all for the input.

@pmrozNow, I am curious why some column references work, while others don't. But I'll keep this in mind. Thanks for sharing this.

 

Regards,

Shaira

ylee
Level III

Re: Column referencing: What is the difference between Column("Example") and :Name("E

Hello Mark,

 

In example below, I am matching Age, Height, and Blood columns for a data table (dt) to a lookup table (dtLUT).

The Column(out) == Column(out) is accepted in some machines running this script, but not for others.

May I know if calling the Column function with a variable is only supported in specific JMP versions ?

 

list = { "Age_Group", "Height_Group", "Blood_Group" };
n = N Items (list);
for (v=1, v<n+1, v++,
	out = Regex (list[v], "^(\S+)_Group$", "\1");
	// dt and dtLUT already opened earlier
	dt << Update (
		With (dtLUT),
		Match Columns (Column(out) == Column(out))
	);
);

Re: Column referencing: What is the difference between Column("Example") and :Name("E

The problem might be the syntax for the << Update(... ) message. Try this syntax for Match Columns() argument:

Match Columns (Column(out) = Column(out))

You are not testing equality. You are specifying a match. See the syntax for this message in the Scripting Index:

match.PNG

ylee
Level III

Re: Column referencing: What is the difference between Column("Example") and :Name("E

I figured out the problem was not related to scripting / environment.  Please ignore my question above, my apologies for the confusion.