- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
JSL character type time convert to numeric nominal
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:"));
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL character type time convert to numeric nominal
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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL character type time convert to numeric nominal
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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL character type time convert to numeric nominal
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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL character type time convert to numeric nominal
Can you post a portion of your data? Perhaps your character time column is not quite in the right format, e.g. leading/trailing spaces etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL character type time convert to numeric nominal
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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL character type time convert to numeric nominal
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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL character type time convert to numeric nominal
Thanks, PMorz....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL character type time convert to numeric nominal
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