Choose Language Hide Translation Bar
Highlighted
PNash
Level II

Recoding multiple columns not working

COLS = 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?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Recoding multiple columns not working

I 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
		);
	);
);
Learn it once, use it forever!

View solution in original post

2 REPLIES 2
Highlighted

Re: Recoding multiple columns not working

I 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
		);
	);
);
Learn it once, use it forever!

View solution in original post

Highlighted
PNash
Level II

Re: Recoding multiple columns not working

The only tweak I had to make to your code was 

As Column( COLS[I] )[][] = 0

to 

As Column( COLS[I] )[] = 0

 but it worked!  Thanks

Article Labels

    There are no labels assigned to this post.