Subscribe Bookmark RSS Feed

Why is it this doesn't work?

:Name("COLUMN_NAME+WITH-CHARACTERS")

OK

str = "COLUMN_NAME+WITH-CHARACTERS"

:Name(str)

Error: Name arg must be quoted string

The only way I've gotten this to work is:

eval(parse(":Name(\!""||str||"\!")"))

which is absurd

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

I use the column function instead:

column(str)

For clarity I include the dataset name as well:

column(dt, str)

Sometimes I've needed to use the as column function.  Not sure if it applies here.

Regards,

Peter

5 REPLIES
Solution

I use the column function instead:

column(str)

For clarity I include the dataset name as well:

column(dt, str)

Sometimes I've needed to use the as column function.  Not sure if it applies here.

Regards,

Peter

ccp

Community Trekker

Joined:

Aug 3, 2011

Hi,

Can you also add some info on the usage of "As Column"? I am trying to pass a column name as a variable to the Split Table function, and I think the "As Column" function will help me do this. What I am trying looks something like this:

columnname = "data1"; // assume there are multiple columns of data like this, data2, data3, etc.

Current  Data Table () << Split ( Split By (:DAY) ), Split (columnname) .... );

I think I need something like an As Column (columnname); statement in there...

Suggestions?

Thanks,

Charles

pmroz

Super User

Joined:

Jun 23, 2011

I'm not sure why you need COLUMN vs AS COLUMN.  It seems to clarify things for JMP.  I mostly use the COLUMN function, but I needed to use the AS COLUMN function in a where clause:

one_dme = "Electrolysis";

tmp_matrix = dmt << get rows where(:Time Period == "Current"

                                   & as column(dmt, eval(one_dme)) == 1);

ccp

Community Trekker

Joined:

Aug 3, 2011

@PMroz

Thanks for your help. I could not get As Column to do anything for me, but your use of "eval" got me thinking, and I was able to get this syntax to work:

columnname = "data1";

Current  Data Table () << Split ( Split By (:DAY) ), Split (eval(columnname)) .... );

Thanks,

Charles

XanGregg

Staff

Joined:

Jun 23, 2011

FYI, Name() isn't a real function (despite the way it looks); it's a quoting mechanism handled by the parser. If you really want to create a name at run-time, use the As Name() function.