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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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