You could do something along the line of below sample code.
proc sql;
create table work.attribs as
select
upcase(name) as _gname,
max(varnum) as varnum,
max(name) as name,
max(length) as len,
max(case when type='char' then '$' else ' ' end) as type,
max(format) as format,
max(informat) as informat,
max(case when missing(label) then ' ' else cats("'",label,"'") end) as label
from dictionary.columns
where
libname='SASHELP'
and memname like 'CLASS%'
group by _gname
order by varnum, _gname
;
quit;
filename codegen temp;
data _null_;
file codegen;
set work.attribs end=_last;
if _n_=1 then put 'attrib';
put name 'length=' type len @;
if not missing(format) then put 'format=' format @;
if not missing(informat) then put 'informat=' informat @;
if not missing(label) then put 'label=' label @;
put;
if _last then put ';';
run;
data want;
%include codegen /source2;
set sashelp.class:;
run;
filename codegen clear;
Ordering by varnum to keep the variable order in the pdv closer to the source data.
Ordering by varnum and name in case varnum is missing like for source data stored in a data base.
... View more