The SAS Output Delivery System and reporting techniques

diplaying a variable name in the columns

Reply
N/A
Posts: 0

diplaying a variable name in the columns

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
SAS Super FREQ
Posts: 8,743

Re: diplaying a variable name in the columns

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
N/A
Posts: 0

Re: diplaying a variable name in the columns

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...
N/A
Posts: 0

Re: diplaying a variable name in the columns

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.
N/A
Posts: 0

Re: diplaying a variable name in the columns

I think you misunderstood, I want both the variable label and the variable name as the column header.
N/A
Posts: 0

Re: diplaying a variable name in the columns

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.
SAS Super FREQ
Posts: 8,743

Re: diplaying a variable name in the columns

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
N/A
Posts: 0

Re: diplaying a variable name in the columns

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;
Ask a Question
Discussion stats
  • 7 replies
  • 178 views
  • 0 likes
  • 2 in conversation