I'm not sure what you mean by "get the code".
But in any case, rather than cobble together your own manual routines there's a much better way:
Set table preferences!
The automatic job will pick up these settings. And any manual call will default to these values too (though you can override them).
exec dbms_stats.set_table_prefs ( 'HR', 'EMPLOYEES', 'STALE_PERCENT', 1 );
exec dbms_stats.set_table_prefs ( 'HR', 'DEPARTMENTS', 'METHOD_OPT', 'FOR ALL COLUMNS SIZE 1' );
exec dbms_stats.set_table_prefs ( 'SH', 'SALES', 'DEGREE', 4 );
There's also procedures to set these at the schema, database, and globally.