Sample 37157: How to capture a title in a macro variable
It might sometimes be useful to capture the value of a global statement into a macro variable. In this case, we are interested in capturing the value of the TITLE statement. You can use PROC SQL code to query the SASHELP.VTITLE dictionary table to get this information.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Create a sample dataset and print it */
title "This is title 1" ;
data one;
do i=1 to 10;
output;
end;
run;
proc print; run;
/* Create a second sample dataset and print it */
title2 "This is title 2";
title3 "This is title 3";
data two;
do j=1 to 5;
output;
end;
run;
proc print; run;
/* Query the dictionary table SASHELP.VTITLE. */
/* Put the value of TEXT into a macro variable */
/* called MYTITLES. Since we have three TITLE */
/* statements, we want the values for TEXT where*/
/* NUMBER is 1, 2, and 3 */
proc sql noprint;
select TEXT into : MYTITLES separated by ", "
from SASHELP.VTITLE
where NUMBER in (1,2,3);
quit;
/* Put the value of the &MYTITLES macro variable to the log */
%put &mytitles;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
457
458 /* Put the value of the &MYTITLES macro variable to the log */
459
460 %put &mytitles;
This is title 1, This is title 2, This is title 3
Type: | Sample |
Topic: | SAS Reference ==> Macro SAS Reference ==> SQL
|
Date Modified: | 2009-09-16 11:43:37 |
Date Created: | 2009-09-11 16:39:56 |
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.1 TS1M3 SP4 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Server | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Professional | 9.1 TS1M3 SP4 | |
Microsoft Windows NT Workstation | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2008 | 9.1 TS1M3 SP4 | |
Microsoft Windows XP Professional | 9.1 TS1M3 SP4 | |
Windows Vista | 9.1 TS1M3 SP4 | |
64-bit Enabled AIX | 9.1 TS1M3 SP4 | |
64-bit Enabled HP-UX | 9.1 TS1M3 SP4 | |
64-bit Enabled Solaris | 9.1 TS1M3 SP4 | |
HP-UX IPF | 9.1 TS1M3 SP4 | |
Linux | 9.1 TS1M3 SP4 | |
Linux on Itanium | 9.1 TS1M3 SP4 | |
OpenVMS Alpha | 9.1 TS1M3 SP4 | |
Solaris for x64 | 9.1 TS1M3 SP4 | |
Tru64 UNIX | 9.1 TS1M3 SP4 | |