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".
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 :
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)
));
And if you want to have then as characters wrap that with Char()
Char(!Is Missing(:Column 1))
pouvez-vous donner un exemple ?
I would use a simple script to do the change.
If you have a column of data that contains zeros and other values
You can use this simple script to change the values
For Each Row(
If( :Y == 0, :Y = 0, :Y = 1 )
)
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 :
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)
));
And if you want to have then as characters wrap that with Char()
Char(!Is Missing(:Column 1))