BookmarkSubscribeRSS Feed
theresagoodyear

Community Trekker

Joined:

Sep 21, 2015

How can I reference a number in jsl?

I am trying to run the same query over five different reporting periods via jsl.  I would like to run a query and reference the reporting period at the top of my script.  As an example:

A=1215

B=1214

C=1213

Select fields from table_A

Select fields from table_B

Select fields from table_C

I keep getting error messages because table_A does not exist.  How can I format my script so that JMP knows I need data from table_1215?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz

Super User

Joined:

Jun 23, 2011

Solution

Re: How can I reference a number in jsl?

Is this what you're trying to do?

A = 1215;

B = 1214;

C = 1213;

dt1 = data table("table_" || char(a));

dt2 = data table("table_" || char(b));

dt3 = data table("table_" || char(c));

Now you can use the three table variables dt1, dt2 and dt3 with SELECT logic.  The example assumes you have a column called ONE_COLUMN.

dt1 << select where(:one_column == 50);

dt2 << select where(:one_column == 61);

dt3 << select where(:one_column == 75);

3 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Re: How can I reference a number in jsl?

In JSL a data table can be referred to explicitly by using its name or by a defined variable (a "pointer" to the particular table). It is important to know which is which as the syntax differ. Moreover, table names must be referred to exactly as is and as strings, i.e. within double quotes. Also when the name is a "number".

I am not sure what goes wrong in your script, but there are many ways to do what you want with JSL. Below is an example that assumes the tables are simply named "1215" etc.

periods = {1215, 1214, 1213};

For(i = 1, i <= N Items(periods), i++,

    dt = Data Table(Char(periods[i]));

    Show(dt);

// do more stuff with dt

);

pmroz

Super User

Joined:

Jun 23, 2011

Solution

Re: How can I reference a number in jsl?

Is this what you're trying to do?

A = 1215;

B = 1214;

C = 1213;

dt1 = data table("table_" || char(a));

dt2 = data table("table_" || char(b));

dt3 = data table("table_" || char(c));

Now you can use the three table variables dt1, dt2 and dt3 with SELECT logic.  The example assumes you have a column called ONE_COLUMN.

dt1 << select where(:one_column == 50);

dt2 << select where(:one_column == 61);

dt3 << select where(:one_column == 75);

theresagoodyear

Community Trekker

Joined:

Sep 21, 2015

Re: How can I reference a number in jsl?

Yes thank you.