Use the stored procedure AR_STATEENGINE_MAINTENANCE. It takes the number of days for which you want to retain the data. All records before that number of days are removed from the database.