The SAS Output Delivery System and reporting techniques

PROC Report with dynamic number of variables

Super Contributor
Posts: 358

PROC Report with dynamic number of variables

Hi All:

I have a dataset that I run through a PROC TRANSPOSE so that data is across rather than down.

As a result of this the number of resulting variables could be 1 to who knows how many - even our client

can't pin down the number of permutations that this will generate.  (It is a reasonable number - most likely

less than 20).

Currently, the client report is generated with a PROC REPORT.   The data coming from the transpose

is to be merged onto the data currently on the client report.

Is there some way to tell the PROC REPORT to include VAR1 - VARx ?  Currently the PROC REPORT is

highly structured with define statements for each variable because the output uses ExcexXP.

Thanks in advance.

Posts: 65

Re: PROC Report with dynamic number of variables

This is probably a little simple-minded for your purposes, but it does in fact work (9.3 TS1M2 on Win 7), assuming your variables out of Transpose are similarly-named.

data one;
input id x1 x2 x3;
1 1 2 3
2 4 5 6
3 7 8 9

proc report data=one nowd;
columns id x:;
define id / order;
define x: / display;
title "Tester";



Respected Advisor
Posts: 3,847

Re: PROC Report with dynamic number of variables

I've often wondered why the DEFINE statement supports the "SAS Variables List" but not the "List of SAS Variables". :smileygrin:

33         proc report data=one nowd;
34          columns id x1-x3;
35          define id / order;
36          define x1 x2 x3 / display;
22-322: Syntax error, expecting one of the following: -, /, :. 
202-322: The option or parameter is not recognized and will be ignored.
37          title "Tester";
38         run;

p.s. You folks that like a log checker take note those error messages don't begin "ERROR:" 

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation