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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: