BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Is there a way to display variable name in the column, when the report is multi page and the column continues into next page. for eg. the report should display trt (type)in the listing at the begining and again when it crosses into next page.

Thanks
7 REPLIES 7
Cynthia_sas
Diamond | Level 26
Hi:
Based on your previous postings, I figure that your question has to do with RTF and COMPUTE BEFORE _PAGE_ in PROC REPORT and whether you can repeat the value of a group variable at a page break. With the new measured RTF, in SAS 9.2, there may be way to do what you want. Otherwise, your best bet for help with this question is to contact Tech Support.

cynthia
deleted_user
Not applicable
Similar question, I would like to print the variable label with the variable name as the column header. I work with MXG on the mainframe and there are many variables to sort through.

Thanks...
deleted_user
Not applicable
proc print data=indata;
run;
quit;

Will print a dataset with the column names being the variable names;

If you set the pagesize option properly for the number of rows on a printed page, the headings will repeat on each page where they should be.
deleted_user
Not applicable
I think you misunderstood, I want both the variable label and the variable name as the column header.
deleted_user
Not applicable
I think you misunderstood, I want both the variable label and the variable name as the column header. The variables in the MXG software have labels with '*' as split characters. Some files could have over 200 variables. When I want to pare down my report to include only the variables I want, it's a hassle going back to proc contents to get the variable name(s) and then putting together the report I want.

Thanks.
Cynthia_sas
Diamond | Level 26
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
deleted_user
Not applicable
Hi,
Use 'id' option in the define statement,so that you will get the column name in the subsequent pages also.

proc report data=dsn;
columns col1 col2 col3;
define col1/id;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 7 replies
  • 1783 views
  • 0 likes
  • 2 in conversation