cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
ENTHU
Level IV

Deleting data that is not within the required date range

I have two dates saved in a text file in the format mm/dd/yyyy. I need to analyse data that falls in this date range and delete all other data.

How can I do this?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Deleting data that is not within the required date range

Here are 2 examples of how you can run an analysis based upon dates read in from a text file

Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 7 ),
	New Column( "ACTUAL_SHORT_DATE",
		Numeric,
		"Continuous",
		Format( "m/d/y", 12 ),
		Input Format( "m/d/y" ),
		Set Values(
			[3612470400, 3614025600, 3618777600, 3614457600, 3613420800,
			3578947200, 3613939200]
		),
		Set Display Width( 154 )
	),
	New Column( "Sample Data",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[0.865467654397147, 0.551025322305757, -0.780534757628151,
			0.590164622893679, -0.084595197133406, 0.93192690045854,
			-0.652714499840696]
		)
	)
);

// Read the data from the text file
textValue = Load Text File( "C:\Temp\DateRange.txt" );

// Parse out the start and end dates
startDate = Informat( Word( 1, textValue, " " ) );
endDate = Informat( Word( 2, textValue, " " ) );

// Select the data that falls within the start
// and end dates
dt << select where(
	:ACTUAL_SHORT_DATE > startDate & :ACTUAL_SHORT_DATE < endDate
);

// Subset
dtSub = dt << Subset(
	Selected Rows( 0 ),
	Rows( [2, 4, 5, 7] ),
	Selected columns only( 0 )
);
	
// Analyze the data
dtSub << Bivariate( Y( :Sample Data ), X( :ACTUAL_SHORT_DATE ) );
Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 7 ),
	New Column( "ACTUAL_SHORT_DATE",
		Numeric,
		"Continuous",
		Format( "m/d/y", 12 ),
		Input Format( "m/d/y" ),
		Set Values(
			[3612470400, 3614025600, 3618777600, 3614457600, 3613420800,
			3578947200, 3613939200]
		),
		Set Display Width( 154 )
	),
	New Column( "Sample Data",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[0.865467654397147, 0.551025322305757, -0.780534757628151,
			0.590164622893679, -0.084595197133406, 0.93192690045854,
			-0.652714499840696]
		)
	)
);

// Read the data from the text file
textValue = Load Text File( "C:\Temp\DateRange.txt" );

// Parse out the start and end dates
startDate = Informat( Word( 1, textValue, " " ) );
endDate = Informat( Word( 2, textValue, " " ) );

// Select the data that falls outside the start
// and end dates
dt << select where(
	:ACTUAL_SHORT_DATE < startDate | :ACTUAL_SHORT_DATE > endDate
);

// Hide and exclude the selected rows
dt << Hide and Exclude;

dt << clear select;
	
// Analyze the data
dt << Bivariate( Y( :Sample Data ), X( :ACTUAL_SHORT_DATE ) );
Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Deleting data that is not within the required date range

1.  What does the text file structure look like?

2. Are the data to be analyzed already in a JMP data table?

3. Is there a valid JMP date column in the data to be analyzed?

 

Basically, what you would do, is to read in he dates from the text file.  Then find all of the rows in the analysis table that meet that requirement, and then subset those rows into a new data table.  Finally, you would run your analysis on the subsetted data table.

 

If you could provide more details about the structure of the text file and the data file/table, I could possibly find a solution for you.

Jim
ENTHU
Level IV

Re: Deleting data that is not within the required date range

Thanks for the response.Attaching sample text file.I have all the data in jmp table that also contains a valid JMP date column.

txnelson
Super User

Re: Deleting data that is not within the required date range

Here are 2 examples of how you can run an analysis based upon dates read in from a text file

Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 7 ),
	New Column( "ACTUAL_SHORT_DATE",
		Numeric,
		"Continuous",
		Format( "m/d/y", 12 ),
		Input Format( "m/d/y" ),
		Set Values(
			[3612470400, 3614025600, 3618777600, 3614457600, 3613420800,
			3578947200, 3613939200]
		),
		Set Display Width( 154 )
	),
	New Column( "Sample Data",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[0.865467654397147, 0.551025322305757, -0.780534757628151,
			0.590164622893679, -0.084595197133406, 0.93192690045854,
			-0.652714499840696]
		)
	)
);

// Read the data from the text file
textValue = Load Text File( "C:\Temp\DateRange.txt" );

// Parse out the start and end dates
startDate = Informat( Word( 1, textValue, " " ) );
endDate = Informat( Word( 2, textValue, " " ) );

// Select the data that falls within the start
// and end dates
dt << select where(
	:ACTUAL_SHORT_DATE > startDate & :ACTUAL_SHORT_DATE < endDate
);

// Subset
dtSub = dt << Subset(
	Selected Rows( 0 ),
	Rows( [2, 4, 5, 7] ),
	Selected columns only( 0 )
);
	
// Analyze the data
dtSub << Bivariate( Y( :Sample Data ), X( :ACTUAL_SHORT_DATE ) );
Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "Example",
	Add Rows( 7 ),
	New Column( "ACTUAL_SHORT_DATE",
		Numeric,
		"Continuous",
		Format( "m/d/y", 12 ),
		Input Format( "m/d/y" ),
		Set Values(
			[3612470400, 3614025600, 3618777600, 3614457600, 3613420800,
			3578947200, 3613939200]
		),
		Set Display Width( 154 )
	),
	New Column( "Sample Data",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[0.865467654397147, 0.551025322305757, -0.780534757628151,
			0.590164622893679, -0.084595197133406, 0.93192690045854,
			-0.652714499840696]
		)
	)
);

// Read the data from the text file
textValue = Load Text File( "C:\Temp\DateRange.txt" );

// Parse out the start and end dates
startDate = Informat( Word( 1, textValue, " " ) );
endDate = Informat( Word( 2, textValue, " " ) );

// Select the data that falls outside the start
// and end dates
dt << select where(
	:ACTUAL_SHORT_DATE < startDate | :ACTUAL_SHORT_DATE > endDate
);

// Hide and exclude the selected rows
dt << Hide and Exclude;

dt << clear select;
	
// Analyze the data
dt << Bivariate( Y( :Sample Data ), X( :ACTUAL_SHORT_DATE ) );
Jim