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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 365 views
  • 0 likes
  • 2 in conversation