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

How can I clear the contents of a specific column in a specific data table?

I have an existing data table and I've updated rows in it, but now I want to have a function that just clears all the rows or sets them all to empty(); also would like it to be really fast because it's a very large table. I tried this but it's quite slow.

 

	Column( my_table, "MY_COL" ) << formula (empty());
	Column( my_table, "MY_COL" ) << Delete Formula;
1 ACCEPTED SOLUTION

Accepted Solutions

Re: How can I clear the contents of a specific column in a specific data table?

Hi,

 

This should be faster; is it fast enough for your needs?

 

my_table[0, loc(my_table << get column names(string), "MY_COL")] = .;

For example:

 

Names Default To Here(1);

my_table = astable(J(1e5, 2, Random Uniform()));

my_table[0, loc(my_table << get column names(string), "Col1")] = .; 

View solution in original post

2 REPLIES 2

Re: How can I clear the contents of a specific column in a specific data table?

Hi,

 

This should be faster; is it fast enough for your needs?

 

my_table[0, loc(my_table << get column names(string), "MY_COL")] = .;

For example:

 

Names Default To Here(1);

my_table = astable(J(1e5, 2, Random Uniform()));

my_table[0, loc(my_table << get column names(string), "Col1")] = .; 
xxvvcczz
Level III

Re: How can I clear the contents of a specific column in a specific data table?

Thanks! This is much faster.