This is not a procedure or macro. This is a dynamic SQL so you should execute the answer of this query. Firt of all you shoul replace the string '<your_db>' and write yours.
select 'select '''||trim(corto)||''' as tabla, DEV.filas as DEV, TES.filas as TEST, DEV.filas-TES.filas
(Select count(1) as filas from <your_db>.dev_'||trim(corto)||')as DEV
(Select count(1) as filas from <your_db>.test_'||trim(corto)||')as TES union all'
case when tablename like 'dev_%' then substr(tablename,5)
when tablename like 'test_%' then substr(tablename,6)
else null end as corto
from dbc.tables a
where tablename like any('dev/_%', 'test/_%') escape '/'
and databasename = '<your_db>')as TMP
group by 1
having count(distinct tablename)=2