cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
KarlK
Level I

binary recoding

How can I simply recode a colum with numeric or missing values into a binary code?

I simply wanto to know, if there is any entry ("1") or none ("0").

For this purpose I would like to recode the colum by recoding "missing value" to "0" and any other numeric value to "1".

2 ACCEPTED SOLUTIONS

Accepted Solutions
hcarr01
Level VI

Re: binary recoding

 

Names Default To Here (1);

dt = current data table();

// Nouvelle colonne : TEST
dt << New Column( "TEST",
	Numeric,
	"Continuous",
	Format( "Best", 12 )
);


// Modifier la formule de colonne : TEST
dt:TEST << Set Formula(
	If( !Is Missing( :data ),
		:TEST = 1,
		:TEST = 0
	)
);

 

 

Vous pouvez rechercher les valeurs manquantes de la BD suivante :

 

hcarr01_0-1697545839068.png

 

View solution in original post

jthi
Super User

Re: binary recoding

Just using Not(IsMissing()) should be enough

Names Default To Here(1);
dt = New Table("Untitled",
	Add Rows(5),
	Compress File When Saved(1),
	New Column("Column 1",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([., 2, ., 5, .])
	)
);

dt << New Column("Check", Numeric, Nominal, Formula(
	!IsMissing(:Column 1)
));

jthi_0-1697560818073.png

And if you want to have then as characters wrap that with Char()

Char(!Is Missing(:Column 1))
-Jarmo

View solution in original post

4 REPLIES 4
hcarr01
Level VI

Re: binary recoding

pouvez-vous donner un exemple ?

txnelson
Super User

Re: binary recoding

I would use a simple script to do the change.

If you have a column of data that contains zeros and other values

txnelson_0-1697543718770.png

You can use this simple script to change the values

For Each Row(
If( :Y == 0, :Y = 0, :Y = 1 )
)

txnelson_1-1697544035217.png

 

Jim
hcarr01
Level VI

Re: binary recoding

 

Names Default To Here (1);

dt = current data table();

// Nouvelle colonne : TEST
dt << New Column( "TEST",
	Numeric,
	"Continuous",
	Format( "Best", 12 )
);


// Modifier la formule de colonne : TEST
dt:TEST << Set Formula(
	If( !Is Missing( :data ),
		:TEST = 1,
		:TEST = 0
	)
);

 

 

Vous pouvez rechercher les valeurs manquantes de la BD suivante :

 

hcarr01_0-1697545839068.png

 

jthi
Super User

Re: binary recoding

Just using Not(IsMissing()) should be enough

Names Default To Here(1);
dt = New Table("Untitled",
	Add Rows(5),
	Compress File When Saved(1),
	New Column("Column 1",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([., 2, ., 5, .])
	)
);

dt << New Column("Check", Numeric, Nominal, Formula(
	!IsMissing(:Column 1)
));

jthi_0-1697560818073.png

And if you want to have then as characters wrap that with Char()

Char(!Is Missing(:Column 1))
-Jarmo