Automatic columns in proc report?

Occasional Contributor
Posts: 6

Automatic columns in proc report?

Hello experts,

                   I am running proc report for a table in rtf. The number of columns are based on a categorical variable in a dataset. Let say a variable has 6 categories.

I have used call symput to get V1 to V6 macro variables.

The question is in column statement how will I detect and provide V1toV6 automatically. If I use another variable it might have 4 categories and then I will hae V1 to V4.

I need something like this,

proc report data=final  nowindows headline headskip split='|' ;

  column _label_  v1 v2 v3 v4 v5 v6;  /* This should be automatic like v1-v&last  because I have macro variable having last number (&last) */

Thanks in advance.

Occasional Contributor
Posts: 6

Re: Automatic columns in proc report?


Respected Advisor
Posts: 3,777

Re: Automatic columns in proc report?

You can use a "SAS Variables List".

column _label_ V:; /*notice the colon*.

define V: / options.....

You will need to make sure the V variables are in the order you like.

Otherwise you can use more code perhaps MACRO to figure out the list and supply it with a macro variable.

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