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:
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
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;
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;
Ok thank you, the PROC REPORT is effectively simpler.
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!
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.
Ready to level-up your skills? Choose your own adventure.