turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- JSL character type time convert to numeric nominal

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 1, 2015 9:58 PM
(1508 views)

I have a Character Col that all input value is in time, like hh:mm:ss (like 05:36:50), I would like to convert it to numeric, nominal type with a format of h:m.

The script I wrote for this request is listed below, but it does not work out as expected, can anyone give it a modify?

dt<<Current Data Table();

dt<< New Column("Time_Set",Numeric, Nominal, Format("h:m"));

dt<< Being data update;

For each row(:Time_Set=Num(":Time Added:"));

dt<< Move Selected Columns ({"Time_Set"},After("Time Added:"));

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Solution

The trailing colon in your column name is what threw me. This code will work:

dt = Current Data Table**()**;

dt << **New Column(**"Time_Set",Numeric, Nominal, Format**(**"h:m"**))**;

for **(**i = **1**, i <= nrows**(**dt**)**, i++,

:time_set**[**i**]** = informat**(**:name**(**"Time Added:"**)[**i**]**, "h:m:s"**)**;

**)**;

7 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 2, 2015 5:03 AM
(943 views)

dt = Current Data Table**()**;

dt << **New Column(**"Time_Set",Numeric, Nominal, Format**(**"h:m"**))**;

for **(**i = **1**, i <= nrows**(**dt**)**, i++,

:time_set**[**i**]** = informat**(**:Time Added**[**i**]**, "h:m:s"**)**;

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 2, 2015 6:40 AM
(943 views)

Hi PMroz,

I tried the script you wrote, but it did not work out. A Time_Set is created under numeric nominal type, but the entire column is blank.

Thanks,

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 2, 2015 6:58 AM
(943 views)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 2, 2015 8:38 AM
(943 views)

Hi PMorz,

The uploaded file is the sample file. Thanks for your help!

please let me know if you cannot open it.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

The trailing colon in your column name is what threw me. This code will work:

dt = Current Data Table**()**;

dt << **New Column(**"Time_Set",Numeric, Nominal, Format**(**"h:m"**))**;

for **(**i = **1**, i <= nrows**(**dt**)**, i++,

:time_set**[**i**]** = informat**(**:name**(**"Time Added:"**)[**i**]**, "h:m:s"**)**;

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 3, 2015 12:14 PM
(943 views)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 8, 2015 8:19 AM
(943 views)

A quick note on the Informat() function – it doesn't *require* a second argument. If you leave it off, JMP will try all the formats it knows to interpret the first argument as a date/time value.

-Jeff

-Jeff