As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

Putting Labels in Titles

From sasCommunity
Jump to: navigation, search

Q: How do I place data set or variable labels in titles?

A: use scl function to open data set and read attributes.


  • expected use: in macro subroutine
  • reason: to avoid placing labels

which often have special characters, such as unmatch parenthesis, ampersand or percent signs into macro variables

  • todo: remove or handle special characters; suggest use translate

testing program:

 /* name: C:\RJF2\SAS-book\Lp-SCL\sas\;
purpose    :
%Let Data = Work.Testing;
%Let Var  = X;
DATA &Data.(label = 'RnD-labels-to-titles');
attrib x length = 4 label = 'variable x label';
PROC Print data = Work.Testing;
%let Dsid   = %sysfunc(open  (&Data.     ));
%let Nobs   = %sysfunc(attrn (&Dsid.,Nobs));
%let Nvars  = %sysfunc(attrn (&Dsid.,Nvars));
%let VarNum = %sysfunc(varnum(&Dsid.,&Var.));
title3 "label, data: %sysfunc(attrc   (&Dsid.,label))";
title4 "label, var : %sysfunc(varlabel(&Dsid.,&Varnum.))";
*CloseExit:;   %let Rc = %sysfunc(close(&Dsid.));


The SAS System      21:53 Saturday, June 26, 2010   1
label, data: RnD-labels-to-titles
label, var : variable x label
Obs    x
 1     1

--macro maven == the radical programmer 01:09, 27 June 2010 (UTC)