Here you go. This is simplified to only consider character extended attributes.
data class;
set sashelp.class;
run;
ods select none;
PROC DATASETS LIBRARY=WORK nolist;
MODIFY class;
XATTR SET VAR
NAME (Values="Name - Missing")
SEX (Values='SEX - Not Missing')
AGE (Range='teenagers')
;
run;
ods output ExtendedAttributesVar=Xattr ;
contents data=class out=contents;
quit;
ods select all;
proc sort data=xattr;
by member AttributeVariable ExtendedAttribute;
run;
proc transpose data=xattr out=xattr_wide(drop=_name_ _label_) ;
by member AttributeVariable;
id ExtendedAttribute;
var AttributeCharValue;
run;
proc sql;
create table my_casebook(drop=member AttributeVariable) as
select a.libname,a.memname,a.varnum,a.name,a.type,a.length,a.format,a.label
, b.*
from contents a
left join xattr_wide b
on a.libname = scan(b.member,1,'.')
and a.memname = scan(b.member,-1,'.')
and upcase(a.name) = b.AttributeVariable
order by 1,2,3
;
quit;
... View more