SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
averageuser
Calcite | Level 5

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.

2 REPLIES 2
averageuser
Calcite | Level 5

?????????????????????????????????

data_null__
Jade | Level 19

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.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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