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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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