Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted

How do I name data table after a cell value

Hello,

 

I have a simple script that combines relevant columns from two data sets, matching by data.

For each batch of data, the column Date contains the same value in every row.

 

My script includes:

              Output Table( "Data 1 and 2"))

 

How would I append a value from the Date column in front of the string, so that the table becomes, for example, "23.09.20 Data 1 and 2".

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How do I name data table after a cell value

Hi,

 

One way to achieve what you're after may be to first capture the value of the date from one of the tables in a separate variable:

 

dt=data table ("Name of First Table");
date=Format(Column(dt,"Name of Date Column")[1],"dd.mm.yyy");

After the join, you can rename the table using the "set name" argument:

joined_table=dt<<join(...);
joined_table<<set name(date || " Date 1 and 2");

Please try that and let us know if it works for you.

View solution in original post

2 REPLIES 2
Highlighted

Re: How do I name data table after a cell value

Hi,

 

One way to achieve what you're after may be to first capture the value of the date from one of the tables in a separate variable:

 

dt=data table ("Name of First Table");
date=Format(Column(dt,"Name of Date Column")[1],"dd.mm.yyy");

After the join, you can rename the table using the "set name" argument:

joined_table=dt<<join(...);
joined_table<<set name(date || " Date 1 and 2");

Please try that and let us know if it works for you.

View solution in original post

Highlighted
txnelson
Super User

Re: How do I name data table after a cell value

Here is an example of how to do this

names default to here(1);
dt = open("$SAMPLE_DATA/big class.jmp");

dt << set name("Data 1 and 2");

// Create a Date column;()
dt << new column("Date", formula(today()),format("m/d/y"));

// Rename the data table
dt << set name(char(month(:Date[1])) || "." || char(day(:date[1])) ||
     "." || char(year(:Date[1])) || " " || char(dt << get name) );
Jim