BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sasuser_8
Obsidian | Level 7

Hi,

 

From this table:

DATA SALE;

INPUT FILE $ TYPE $ VAR1 ;

CARDS;

1254 100A 52 
3652 200 36 
1254 100A 36 
3652 200 65 
3652 200 6 
2541 300 65 
;

RUN;

I did a proc tabulate:

PROC TABULATE
DATA=SALE;	
	
	VAR VAR1;
	CLASS FILE /	ORDER=UNFORMATTED MISSING;
	TABLE

	/* Dimension de ligne */
FILE={LABEL=""},

/* Dimension de colonne */
VAR1*  Sum={LABEL=""}*F=BESTX12.

/* Options de la table */
/ BOX={LABEL="FILE"} 		;
	;

I would like to achieve the following result:

tabulate.png

 

Each file has the same type. As it is a character variable, I don't know how to integrate it into the proc tabulate.

 

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Unless there are other bits you aren't showing then perhaps this is more of a PROC Report item.

 

proc report data=sale;
  columns file type var1;
  define file/group;
  define type/group;
  define var1 / 'sum_var1';
run;

Report by default will sum numeric variables. You can see how to provide the column heading text other than the default variable label.

 

 

Tabulate could look like this but aligning multiple row headings can be problematic if that is critical.

PROC TABULATE DATA=SALE;	
	VAR VAR1;
	CLASS FILE /	ORDER=UNFORMATTED MISSING;
   class type;
	TABLE 	/* Dimension de ligne */
      FILE={LABEL=""} * type='',

      /* Dimension de colonne */
      VAR1*  Sum={LABEL=""}*F=BESTX12.

      /* Options de la table */
      / BOX={LABEL="FILE  Type"} 		;
run;

 

 

 

View solution in original post

2 REPLIES 2
ballardw
Super User

Unless there are other bits you aren't showing then perhaps this is more of a PROC Report item.

 

proc report data=sale;
  columns file type var1;
  define file/group;
  define type/group;
  define var1 / 'sum_var1';
run;

Report by default will sum numeric variables. You can see how to provide the column heading text other than the default variable label.

 

 

Tabulate could look like this but aligning multiple row headings can be problematic if that is critical.

PROC TABULATE DATA=SALE;	
	VAR VAR1;
	CLASS FILE /	ORDER=UNFORMATTED MISSING;
   class type;
	TABLE 	/* Dimension de ligne */
      FILE={LABEL=""} * type='',

      /* Dimension de colonne */
      VAR1*  Sum={LABEL=""}*F=BESTX12.

      /* Options de la table */
      / BOX={LABEL="FILE  Type"} 		;
run;

 

 

 

sasuser_8
Obsidian | Level 7

Ok thank you, the PROC REPORT is effectively simpler.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 719 views
  • 0 likes
  • 2 in conversation