cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
sophiaw
Level III

Selecting Multiple Rows and Imputing a Value in a Column

Hi,

I have a data table where I created an empty column, and I wanted to input values into that column based on the rows selected. I have a list of search parameters, and I can select which rows I want based on the list I input, but I just want to put the value of the list into the empty column for all the selected rows. I have most of the script working, but I just can't get the last part which is actually inputting the value into the new column for all the selected rows. Any suggestions?

group_gender = {"Male","Female"};

results << New Column("Gender", Character, Nominal);


For(i = 1, i < nitems(group_gender), i++,

     results << Select Where(Contains(:Names,group_gender));

     selRows = results << getSelectedRows;

     Column(results, Gender[selRows]) = eval(group_gender);

);

When I run this, I get an error "attempting to assign to an object that is not an L-value". Is there a way I can just change a column for all the selected rows to some value?

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Selecting Multiple Rows and Imputing a Value in a Column

Use AsColumn(dt,col) for assignment and place the index outside the parentheses.

For( i = 1, i <= NItems( group_gender ), i++,

    results << Select Where( Contains( :Names, group_gender[i] ) );

    selRows = results << getSelectedRows;

    AsColumn( results, "Gender" )[selRows] = group_gender[i];

    // this works to:

    // results:Gender[selRows] = group_gender;

);

View solution in original post

2 REPLIES 2
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Selecting Multiple Rows and Imputing a Value in a Column

Use AsColumn(dt,col) for assignment and place the index outside the parentheses.

For( i = 1, i <= NItems( group_gender ), i++,

    results << Select Where( Contains( :Names, group_gender[i] ) );

    selRows = results << getSelectedRows;

    AsColumn( results, "Gender" )[selRows] = group_gender[i];

    // this works to:

    // results:Gender[selRows] = group_gender;

);

sophiaw
Level III

Re: Selecting Multiple Rows and Imputing a Value in a Column

Thank you MS! I knew that last line had to be wrong, and that fixed it!

Recommended Articles