The SAS Output Delivery System and reporting techniques

tabulate columns between class levels

Reply
Super Contributor
Posts: 292

tabulate columns between class levels

I'm using the table statement as shown below. InvenDate has 2 levels and both levels have data under Prod_Grp_Dim_Cd and Slab_Loc_Dim_Cd. I'd like to change the table so that Slab_Loc_Dim_Cd is reported for level 2 but not for level 1 of InvenDate. I tried adding two columns to the data (InvenDate1 & InvenDate2) and building a table statement (the second one below) that would concatenate across the page but it gets messed up with missing values in InvenDate1 and InvenDate2.

Looking for suggestions ... Thanks

table SLAB_SOURCE_DIM_CD=' '*
(SLAB_GRD_FAM_NAME=' ' all) all,
InvenDate='Inventory Status as of'*
(PROD_GRP_DIM_CD='Category' all SLAB_LOC_DIM_CD='Location')
*SLAB_TON=' '*sum=' '*;



table SLAB_SOURCE_DIM_CD=' '*
(SLAB_GRD_FAM_NAME=' ' all) all,
InvenDate1='Inventory Status as of'*
(PROD_GRP_DIM_CD='Category' all)
*SLAB_TON=' '*sum=' '

InvenDate2='Inventory Status as of'*
(PROD_GRP_DIM_CD='Category' all SLAB_LOC_DIM_CD='Location')
*SLAB_TON=' '*sum=' '* ;
Super Contributor
Posts: 260

Re: tabulate columns between class levels

Here is a little code with the SASHELP.CLASS dataset. Does it look like what you want to do ? If so, just use the same idea, replacing the "1" values in the new variables by SLAB_TON.
[pre]
DATA work.class ;
SET sashelp.class ;
IF sex="F" THEN sexF = 1 ;
ELSE sexM = 1 ;
RUN ;
PROC FORMAT ;
VALUE ages
LOW - 14 = "14 -"
OTHER = "15 +" ;
VALUE weights
LOW - 100 = "<100 lb"
OTHER = ">100 lb" ;
RUN ;
PROC TABULATE DATA = work.class F= 7. ;
CLASS age weight ;
VAR sexF sexM ;
FORMAT age ages. weight weights. ;
TABLE weight,
(sexM="# boys"*age=""*SUM="" sexF="# girls"*SUM="") ;
RUN ;
Super Contributor
Posts: 292

Re: tabulate columns between class levels

Olivier;

Here's what I was looking for - and you helped me to get there. Thank you!

DATA work.class ;
SET sashelp.class ;
IF sex="F" THEN do;sexF = 1 ;sex2=1;end;
ELSE do;sex2=2;end;;
RUN ;
PROC FORMAT ;
VALUE ages
LOW - 14 = "14 -"
OTHER = "15 +"
;
VALUE weights
LOW - 100 = "<100 lb"
OTHER = ">100 lb"
;
RUN ;


PROC TABULATE DATA = work.class F= 7. ;
CLASS age weight sex;
VAR sexF sex2 ;
FORMAT age ages. weight weights. ;
TABLE weight,
sex*sex2*sum sexF ;
RUN ;
Ask a Question
Discussion stats
  • 2 replies
  • 121 views
  • 0 likes
  • 2 in conversation