Recoding multiple columns not workingCOLS = DEMAND << GET COLUMN NAMES;
FOR EACH ROW( FOR (I = 5, I <= N ITEMS(COLS), I++, IF(ISMISSING(COLS[I]), COLS[I]=0)));
I have 20+ columns that I need to recode from empty to 0. I can't seem to get a loop to work, so I'm clearly missing something. Can anyone help?
Re: Recoding multiple columns not workingI think you have to convert the character string representing the name to a column reference. You need to add empty [ ] so that JMP knows to index the row.
COLS = DEMAND << GET COLUMN NAMES;
For Each Row(
For( I = 5, I <= N Items( COLS ), I++,
If( Is Missing( As Column( COLS[I] )[] ),
As Column( COLS[I] )[][] = 0
);
);
);
Re: Recoding multiple columns not workingThe only tweak I had to make to your code was
<SPAN class="token function">As Column</SPAN><SPAN class="token punctuation">(</SPAN> COLS<SPAN class="token punctuation">[</SPAN>I<SPAN class="token punctuation">]</SPAN> <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token punctuation">]</SPAN> <SPAN class="token operator">=</SPAN> <SPAN class="token number">0</SPAN>
to
<SPAN class="token function">As Column</SPAN><SPAN class="token punctuation">(</SPAN> COLS<SPAN class="token punctuation">[</SPAN>I<SPAN class="token punctuation">]</SPAN> <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token punctuation">]</SPAN> <SPAN class="token operator">=</SPAN> <SPAN class="token number">0</SPAN>
but it worked! Thanks