Hi:
There are some automatic "dictionary" tables that are created in a SAS session that may help you. As long as you have your MXG librefs defined in a session, you should be able to programmatically get a list of variable names and their labels by running a PROC SQL against DICTIONARY.COLUMNS.
Here are some user group papers that outline what the "dictionary" tables do:
http://www2.sas.com/proceedings/sugi30/070-30.pdf
http://www2.sas.com/proceedings/sugi29/237-29.pdf
http://www.codecraftersinc.com/pdf/DictionaryTablesRefCard.pdf
http://www.lexjansen.com/pharmasug/2006/tutorials/tu03.pdf
http://www.qsl.net/kd6ttl/sas/sqlutilov.pdf
Here is an example of creating a data set from the dictionary tables...going after dictionary.columns for name and building a string that you could cut and paste into a label statement.
[pre]
** make table to use later;
** cut and paste newlabel value into LABEL;
** statement or for reference;
proc sql;
create table work.paste as
select name,
trim(name)||'='||quote(trim(name)||'!'||trim(label)) as newlabel
from dictionary.columns
where libname = "SASHELP" and
memname = "PRDSALE";
quit;
options nocenter;
proc print data=work.paste noobs;
title 'data set from proc sql query on dictionary.columns';
title2 "for SASHELP.PRDSALE";
run;
title;
footnote;
[/pre]
The output from the PROC PRINT would be:
[pre]
data set from proc sql query on dictionary.columns
for SASHELP.PRDSALE
name newlabel
ACTUAL ACTUAL="ACTUAL!Actual Sales"
PREDICT PREDICT="PREDICT!Predicted Sales"
COUNTRY COUNTRY="COUNTRY!Country"
REGION REGION="REGION!Region"
DIVISION DIVISION="DIVISION!Division"
PRODTYPE PRODTYPE="PRODTYPE!Product type"
PRODUCT PRODUCT="PRODUCT!Product"
QUARTER QUARTER="QUARTER!Quarter"
YEAR YEAR="YEAR!Year"
MONTH MONTH="MONTH!Month"
[/pre]
In this example, I set the split character to ! so you'd put split='!' in your PROC PRINT when you cut and pasted these label strings into your code. If you wanted to keep * as the split character, then you'd replace the ! with * in the SQL query. Then your split option in PROC PRINT would be split='*'.
There are many macro solutions you could build using the dictionary tables.
cynthia