cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Phil_Nash
Level III

Recode a value in a column with a formula instead of a static value

The original value that is in the table that I want to recode will always be 01/01/1900.  I want to recode that to today's date.  This only returns a blank, and not today's date.  Any idea what I need to change?

 

Thanks!

 

Transfers << Begin Data Update;
Transfers << Recode Column(
	Transfers:OrderDate,
	{Map Value( _rcOrig, {-126144000, short date(today())}, Unmatched( _rcNow ) )},
	Update Properties( 1 ),
	Target Column( :OrderDate )
);
Transfers << End Data Update;
2 REPLIES 2

Re: Recode a value in a column with a formula instead of a static value

I am not sure that the source column and the destination column can be the same data column. Here is the example from the scripting index:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = New Column( :age );
col << Data Type( "Character" );
dt << Recode Column(
	:age,
	{If(
		_rcNow >= 17, "Older",
		_rcNow >= 15, "Middle",
		"Younger"
	)},
	Target Column( col )
);
hogi
Level XIII

Re: Recode a value in a column with a formula instead of a static value

To recode entries in a column and save the result to the same column, one can select In Place from the drop down menu:

hogi_0-1759868337446.png

In the JSL code the target column will match the input column.

Hm, Why does the code not work? 

a) Short Date() converts the date to a String - but the column is numeric.

b) even after removing short date() it doesn't work. Because  Map value() doesn't allow expressions? maybe:

hogi_1-1759868519259.png

 

So let's try:

Transfers = New Table( "transfers",
	Add Rows( 1 ),
	Compress File When Saved( 1 ),
	New Column( "OrderDate",
		Format( "y/m/d"),
		Set Values( [-126144000] )
	)
);

Transfers << Begin Data Update;
Eval (Eval Expr(Transfers << Recode Column(
	Transfers:OrderDate,
	{Map Value( _rcOrig, {-126144000, Expr(today())}, Unmatched( _rcNow ) )},
	Update Properties( 1 ),
	Target Column( :OrderDate )
)));
Transfers << End Data Update;

  

Recommended Articles