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
- :
- Re: Recode a column using JSL

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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Recode a column using JSL

Apr 2, 2019 7:03 AM
(841 views)

I would like to recode (by JSL) a column using the 'Split On' advanced option 'Split Delimiter'= (Text)...

9 REPLIES 9

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

Re: Recode a column using JSL

Did you perform the task manually to verify the results are what you want? If so, did you save the results in a new data column with a formula? If so, then examine the formula to see how it might be done in a script.

Learn it once, use it forever!

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

Re: Recode a column using JSL

Hi, Mark

Yes but the result is a match formula

I would like, if possible, to script the recoding, using recode options

something like

dt_:var_name << recode(split delimiter text("String"))....

I don't know if that's possible.

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

Re: Recode a column using JSL

My suggestion is similar to @markbailey. But rather than saving the column's formula, you can manually create the recode, but before actually completing the recode, you can go to the red triangle, and select

Script==>Save to Script Window

and it will show you the script necessary to generate the recode you have specified

```
Current Data Table() << Begin Data Update;
dc1 = New Column( :weight );
dc1 << Set Name( "weight 2 2" );
Current Data Table() << Go to( dc1 );
Current Data Table() << Move Selected Columns( after( :weight ) );
For Each Row(
dc1[] = Match( :weight,
64, 60,
67, 60,
74, 70,
79, 70,
81, 80,
84, 80,
85, 80,
91, 90,
92, 90,
93, 90,
95, 90,
98, 90,
99, 90,
104, 100,
105, 100,
106, 100,
107, 100,
111, 110,
112, 110,
113, 110,
115, 110,
116, 110,
119, 110,
123, 120,
128, 120,
134, 130,
142, 140,
145, 140,
172, 170,
:weight
)
);
Current Data Table() << End Data Update;
```

Jim

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

Re: Recode a column using JSL

Thank you but I'ld to avoid the match scripting because this recoding will be implemented within a global script and the text delimiter could be changed by my user depending on the column to be recoded.

That's why i'ld prefer, if possible, to write the recoding function using options...

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

Re: Recode a column using JSL

I think that you need to consider all the character functions in JSL to make a formula of your own and either save it as a new column (recoded values) or use the expression to compute the values row-wise without a script.

Your descriptions so far are too vague to permit anyone to offer more specific suggestions.

Learn it once, use it forever!

Highlighted
##

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

Re: Recode a column using JSL

Thank you Mark

If I understand well, the recode function doesn't exist in JSL...

So, we're not able to script what we do manually using the red triangle options (Split on, advanced, ...) proposed when we recode a column.

I'll use the basic character functions...

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

Re: Recode a column using JSL

That is correct, Recode is a column action, not a JSL function. There is a data column message << Recode that opens the interactive recoding editor but there is nothing to automatically apply recoding rules. On the other hand, the collection of character string functions is rich and offers a lot of help.

Can you provide examples of the original values and the desired recoded results? That might allow us to make better suggestions, if you still want more help.

Learn it once, use it forever!

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

Re: Recode a column using JSL

Right, so you know it works. Now, copy that formula and paste it over the 'recode expression' in this script to accomplish the same thing.

```
Current Data Table() << New Column( "Recoded",
Formula( recode expression )
);
```

Learn it once, use it forever!

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

Re: Recode a column using JSL

Thank you all

This problem is solved...