adding labels in multiple sas tables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

adding labels in multiple sas tables

Hi,

 

I have to add labels to columns in about 100 sas tables that are in one libary.

 

I have one table with variables that contains

1  name of the tables

2 name of columns in these tables

3 name of labels that I shoud add

 

how can i do it ? i was thinking about using proc datasets and macros.


Accepted Solutions
Solution
‎06-07-2017 06:41 AM
Super User
Posts: 6,946

Re: adding labels in multiple sas tables

Yes (proc datasets) and no (macros).

proc sort data=column_labels;
by table_name;
run;

data _null_;
set column_labels end=done;
by table_name;
if _n_ = 1 then call execute("proc datasets library=your_lib;");
if first.table_name then call execute("modify " !! trim(table_name) !! "; attrib ");
call execute(trim(column_name) !! " label='" !! trim(label) !!"' ");
if last.table_name then call execute("; "); * ends attrib statement;
if done then call execute("quit; run;");
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎06-07-2017 06:41 AM
Super User
Posts: 6,946

Re: adding labels in multiple sas tables

Yes (proc datasets) and no (macros).

proc sort data=column_labels;
by table_name;
run;

data _null_;
set column_labels end=done;
by table_name;
if _n_ = 1 then call execute("proc datasets library=your_lib;");
if first.table_name then call execute("modify " !! trim(table_name) !! "; attrib ");
call execute(trim(column_name) !! " label='" !! trim(label) !!"' ");
if last.table_name then call execute("; "); * ends attrib statement;
if done then call execute("quit; run;");
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 14

Re: adding labels in multiple sas tables

brilliant ! thank you !
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 127 views
  • 3 likes
  • 2 in conversation