BookmarkSubscribeRSS Feed
Bill
Quartz | Level 8
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=' '* ;
2 REPLIES 2
Olivier
Pyrite | Level 9
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 ;
Bill
Quartz | Level 8
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 ;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 656 views
  • 0 likes
  • 2 in conversation