Subscribe Bookmark RSS Feed

Try/Eval method for columns that are empty

anders_bankefor

Community Trekker

Joined:

Dec 8, 2015

Hi,

I've tried to use examples here from disucssions regarding empty columns but with no success. Does anyone know how I can achive the following?

Depending on the imported data I will either have 1 or 6 columns with data (they will allways be imported but some will be imported without containing any data).

try (

if column contains data put it into a list

else

try next column

)

the 6 columns of data has a number of columns inbetween them that is not off interest. so for example:

column 1 (try/eval) column 2 (not interested in) ..... Column 6 (try/eval) etc.

I've tried the missing data pattern function and tried to modify if(NRow(Loc(IsMissing(m[0,c]))) == NRow(m) without success.

BR

Anders

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Here is a simple script that will return a list with the names of all of the columns that contain data

Names Default To Here( 1 );

dt = Current Data Table();

HaveDataList = {};

For( i = 1, i <= N Cols( dt ), i++,

       If( Col Number( Column( dt, i ) ) > 0,

              Insert Into( HaveDataList, Column( dt, i ) << get name )

       )

);

Jim
2 REPLIES
Solution

Here is a simple script that will return a list with the names of all of the columns that contain data

Names Default To Here( 1 );

dt = Current Data Table();

HaveDataList = {};

For( i = 1, i <= N Cols( dt ), i++,

       If( Col Number( Column( dt, i ) ) > 0,

              Insert Into( HaveDataList, Column( dt, i ) << get name )

       )

);

Jim
anders_bankefor

Community Trekker

Joined:

Dec 8, 2015

This function was what I was looking for, thank you.      

If( Col Number( Column( dt, i ) ) > 0,

              Insert Into( HaveDataList, Column( dt, i ) << get name )

       )