cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
TomF
Level III

JSL: How to change a column to a 1-byte integer

I'm working with large files and am trying to be more thrifty when it comes to memory. I want to change the data type for some columns to "1-byte integer" using JSL but can't figure it out.

I have set my Table preferences to "Allow short numeric data format," and I can change a column's data type by hand, but I need to do it with JSL.  If I change the data type by hand and then copy and paste the column into a script I see the data type for a 1-byte integer appears to be "Numeric(1)" . Maybe that is a clue.

Here are some things I've tried:

dt = open("$sample_data/big class.jmp");
dt:age << Data Type(1-byte integer);	//error "Agument to Type..."
dt:age << Data Type("1-byte integer");	//error "Agument to Type..."
dt:age << Data Type(Character);			//this works, changes to Character
dt:age << Data Type(Numeric);			//this works, changes to Numeric
dt:age << Data Type(Numeric(1));		//no error, but data type stays Numeric

It's probably something simple, but I've found no solution in the JMP Help or Community so far. Any help would be appreciated. (I'm on JMP 16.1.)

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: JSL: How to change a column to a 1-byte integer

Search Scripting Index with "1-byte":

jthi_1-1642107521176.png

 

Seems to be working:

jthi_0-1642107515862.png

 

-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: JSL: How to change a column to a 1-byte integer

Search Scripting Index with "1-byte":

jthi_1-1642107521176.png

 

Seems to be working:

jthi_0-1642107515862.png

 

-Jarmo
TomF
Level III

Re: JSL: How to change a column to a 1-byte integer

Thanks! I was hoping to find a way to tell JMP when I create the column that it's only going to be ones and zeros and therefore 1-byte integer is plenty. 

 

It seems strange to me that I can force a column to be a 1-, 2-, or 4-byte integer using the column properties menus, but I can't do it with scripting.  I wonder if this has to do with the fact that there is a preference option that allows these data types and JSL is not "smart" enough to know whether this is enabled but the GUI is.

TomF_0-1642171714249.png

 

Compressing is a solution, but I'd still be interested if anyone knows how to set modeling type before populating the column.

 

Re: JSL: How to change a column to a 1-byte integer

Here is an example to make a new variable as a data column with a short word length for signed integers using a single byte.

 

Names Default to Here( 1 );

// open target data table
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// set JMP preferences to accept short numeric words
Set Preference( Allow short numeric data format( 1 ) );

// create a new column using shortened numeric data type
shorty = dt << New Column( "Short Age", Numeric( 1 ), Continuous,
	Values( :age << Get As Matrix )
);

// your done. maybe set preference back to default
Set Preference( Allow short numeric data format( 0 ) );
pmroz
Super User

Re: JSL: How to change a column to a 1-byte integer

To set an existing column to 1-byte format look at this example:

// set JMP preferences to accept short numeric words
Set Preference( Allow short numeric data format( 1 ) );

dt = New Table( "Untitled",
	Add Rows( 3 ),
	New Column( "1 Byte Format",
		Numeric( 1 ),
		"Continuous",
		Set Values( [1, 2, 3] )
	),
	New Column( "New Column",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [4, 5, 6] )
	)
);

dt:New Column << set data type("numeric", 1);