BookmarkSubscribeRSS Feed
Ebele
Obsidian | Level 7
Is there a way to display the Column Description as it is registered in the metadataserver, instead of the column labels or the column names?

Thanks,
Ebele
2 REPLIES 2
ChrisHemedinger
Community Manager
Yes.

Select Tools->Update Library Metadata (don't worry, we're not going to actually update anything).

On the first page of the wizard, select the library that contains the table you care about.

On the second page, accept the default option of "Report on the contents of the library, as registered in the metadata repository".

Then click Finish. The resulting report should contain the information you need.

If you would rather have a SAS program to do this, try running this (replacing your libref and library name at the top):

[pre]
%let libref = NEWCHOC;
%let metaLibName = Appalachian Chocolates;

/* free the library if it is currently assigned */
%macro cleartemplib(libtofree);
%if %sysfunc(libname(&libtofree)) ne 0 %then
%put NOTE: Libref &libtofree could not be unassigned;
%else
%put NOTE: Libref &libtofree has been unassigned;
%mend;

/* clear existing definition, if any */
%cleartemplib(&libref);

/* ensure library is assigned */
libname &libref meta library="&metaLibName";

/* list contents of the library, according to the metadata */
ods noproctitle;
title "Contents of library ""&metaLibName""";
proc datasets lib=&libref memtype=(data view) nolist;
contents data=_all_ varnum ;
run;
quit;
ods proctitle;
title;
[/pre]

Chris
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Ebele
Obsidian | Level 7
Hi Chris,
Thanks.

I have a SQL Server table which I register in the metadata.
I want to add column labels (a description) to the registered SQL table.

The piece of SAS code which does the trick:

data _null_;
length uri urik $256
id_table $256
desc $256
naam_tabel $32
NameColumn $256;
rc=1;arc=0; n=1;

do while(rc>0);
rc=metadata_getnasn("omsobj:DatabaseSchema?@Name = 'CDW'", "Tables", n, uri);
arc=1;
if (rc>0) then do;
arc=metadata_getattr(uri,"ID",id_table);
brc=metadata_getattr(uri,"Name",naam_tabel);
end;
if (arc=0) then put id_table=;
rck=1;
k=1;
do while (rck>0);
rck=metadata_getnasn("omsobj:"!!compress(id_table), "Columns", k, urik);
rcn = metadata_getattr(urik, 'Name', NameColumn);
rcm = metadata_getattr(urik, 'Desc', desc);
rcaap=metadata_setattr(urik,"Desc","Test label description");
put "Label=" desc " Name column: " NameColumn;
k+1;
end; /* while rck>0 */
n=n+1;
end;
run;

Now you have the description in the metadata and I was looking for a way to use it in Enterprise guide when viewing tables.
At a first glance I thought Enterprise Guide ignored the description field.
But after reconnecting to the metadataserver the description field is displayed.


Regards,
Ebele

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3572 views
  • 0 likes
  • 2 in conversation