BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
anthony
Community Trekker

Changing DT values using JSL

Hi, I'm fairly new to SAS software in general, and even more unfamiliar with JSL. I'm making very simple automation scripts and am running into issues.

I would like to (In a data table of 600,000+ entries)

1) Select certain rows based on specific criteria

ex: dt<< Select Where(age>15)

2) Manipulate a specific column based on that row selection

ex: For those rows with age>15 change the column "Eleigible" from "No" to "Yes"

I do not know how to code this second part, I'd imagine it's pretty simple. I've read the JMP basic scripting tutorial, but I can't seem to figure out how to execute this simple operation.

Any help would be appreciated.

-Anthony

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Changing DT values using JSL

It's not too hard.  Here's an example using Big Class:

dt = open("$sample_data\Big Class.jmp");

one_set_rows = dt << get rows where(:sex == "F");

column(dt, "name")[one_set_rows] = "Female";

Basically you use GET ROWS WHERE to get a matrix of row numbers that match a certain condition.  The last line allows you to put one value in all rows found that match the condition.

0 Kudos
2 REPLIES 2
pmroz
Super User

Changing DT values using JSL

It's not too hard.  Here's an example using Big Class:

dt = open("$sample_data\Big Class.jmp");

one_set_rows = dt << get rows where(:sex == "F");

column(dt, "name")[one_set_rows] = "Female";

Basically you use GET ROWS WHERE to get a matrix of row numbers that match a certain condition.  The last line allows you to put one value in all rows found that match the condition.

0 Kudos
MTOF
Community Trekker

Re: Changing DT values using JSL

Or - if you have to make a new column anyway:

dt<<new column("Eligible",character,formula(If(:Age < 15, "no", :Age >= 15, "yes")));

BR, Marianne

0 Kudos