A good example for proc select into/ dictionary. for your reference.
proc sql;
reset noprint;
select '%let n_'||trim(memname)||'='||trim(put(nobs,best12.-L))||';'
into :doit separated by ' '
from dictionary.tables
where libname = 'SASHELP'
and memtype = 'DATA'
;