cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Mcc99
Level I

How to Code a new column by referencing text in second column?

How would I code a new column to fill each cell with a specific text based on the text in a second column? I have a "well" column with A1-A100. I need to create a second column with Treatment "A", for wells A1-A10, "B" for wells A11-A20, etc.

Thanks! 

3 REPLIES 3
jthi
Super User

Re: How to Code a new column by referencing text in second column?

Mcc99
Level I

Re: How to Code a new column by referencing text in second column?

Is there a way to do it by chunks/groups in the recode platform though? Doing it by hand for 100+ samples and multiple datasets would take quite a bit of time. 

jthi
Super User

Re: How to Code a new column by referencing text in second column?

Have you tried it? Recode platform will provide you with a script, such as

ocal({dt, col1},
	dt = Data Table("Untitled");
	dt << Begin Data Update;
	col1 = dt << New Column(dt:Column 1);
	col1 << Set Name("Column 1 2");
	dt << Move Selected Columns({col1}, after(dt:Column 1));
	For Each Row(
		dt,
		col1[] = Map Value(
			dt:Column 1,
			{"A10", "A1", "A2", "A1", "A3", "A1"},
			Unmatched(dt:Column 1)
		)
	);
	dt << End Data Update;
);

You can then modify that as needed and maybe use something like Workflow builder to make it work with different tables. Or you can script it (Get Data Table List() and For Each are good starting points for this).

-Jarmo