Hello,
data test;
format var4 date9.;
input var1 $2. var2 :$10. var3 $ var4 date9. var5 var6 var7 :$20. var8 ;
cards;
T1 septembre A 01dec2016 71 6 traitement-c 6
T1 septembre A 01dec2016 . 13 traitement-c 8
T2 septembre A 01dec2016 . 14 traitement-c 61
T2 septembre A 01dec2016 . 0 traitement-s 69
T3 septembre A 01dec2016 . 0 traitement-v 107
T3 septembre A 01dec2016 811 3 traitement-c 46
T1 septembre A 01dec2016 . 6 traitement-c 59
T1 septembre A 01dec2016 . 7 traitement-c 6
T1 septembre A 01dec2016 . 9 traitement-c 6
T1 septembre A 01dec2016 . 61 traitement-c 6
T2 septembre A 01dec2016 . 15 traitement-c 6
;run;
proc tabulate data=test;
class var1 var2 var3 var4 var6 var7;
var var5 var8;
table var5='NB1' *sum=''
var8='NB2'*sum=''
var8=''*var1=''*reppctsum=''*f=mypct.
, var3=''*var2=''
/box="M";
run;
Thank you
Please attach images as image files in formats such as jpeg, gif or png. Microsoft doc files have potentials for virus and many users here either will not open them or are blocked by corporate policy.
I am going to guess that you don't want the "empty" column before the T1 T2 and T3.
If that is the case then try:
/box="M" row=float;
Thank you
hello,
sorry for format of attached figure. I have this message
The file figure2.jpg does not have a valid extension for an attachment and has been removed. sas,txt,csv,zip,pdf,ics,sx,sxs,doc,docx,xls,xlsx,egp,sav,sas7bdat,ctm,ctk,rtf are the valid extensions.
we can realize with proc tabulate the restitution as shown in the attached figure.
thank you
Hi:
I don't like to open .docx files. Typically, I take screen shots with PrntScr and then save the image to a .PNG or .JPG file. However, with a slight modification of your code, I can illustrate why the ROW=FLOAT suggestion was the correct one.
By default, TABULATE wants you to know EXACTLY which variables are used in the ROW and COLUMN dimensions by showing both the variable name/label and the statistic name, where appropriate. So in Example 1, modified from your example, you can see how every cell whether header cell or data cell has a purpose and is filled appropriately based on your TABLE statement. But if you "blank" out sum and blank out "reppctsum" in the row header area, then that will leave you with an empty area on each row. Similarly, if you blank out the column headers for VAR8, VAR5, etc, that will leave you more blank areas. TABULATE is smart enough to get rid of most of them, but compare output 1a with output 1b in the picture below:
The undesired "lines" are really the cell borders for the suppressed row header labels. So now comes ROW=FLOAT to the rescue. Using that option causes the undesired empty cells to be suppressed, as shown in output 2:
and here's the code to produce all of the above outputs.
cynthia
The code:
data test;
format var4 date9.;
input var1 $2. var2 :$10. var3 $ var4 date9. var5 var6 var7 :$20. var8 ;
cards;
T1 septembre A 01dec2016 71 6 traitement-c 6
T1 septembre A 01dec2016 . 13 traitement-c 8
T2 septembre A 01dec2016 . 14 traitement-c 61
T2 septembre A 01dec2016 . 0 traitement-s 69
T3 septembre A 01dec2016 . 0 traitement-v 107
T3 septembre A 01dec2016 811 3 traitement-c 46
T1 septembre A 01dec2016 . 6 traitement-c 59
T1 septembre A 01dec2016 . 7 traitement-c 6
T1 septembre A 01dec2016 . 9 traitement-c 6
T1 septembre A 01dec2016 . 61 traitement-c 6
T2 septembre A 01dec2016 . 15 traitement-c 6
;run;
proc format;
picture mypct low-high='009.99%';
run;
title; footnote;
proc tabulate data=test;
title '1a) PROC TABULATE withOUT row=float';
title2 'and showing ALL labels for column and row headers';
class var1 var2 var3 var4 var6 var7;
var var5 var8;
table var5*sum
var8*sum
var8*var1*reppctsum*f=mypct.
,
var3*var2
/box="M";
run;
proc tabulate data=test;
title '1b) PROC TABULATE withOUT row=float';
title2 'but using blanks for most labels';
title3 'has undesired dividers in the row header area';
class var1 var2 var3 var4 var6 var7;
var var5 var8;
table var5='NB1' *sum=''
var8='NB2'*sum=''
var8=''*var1=''*reppctsum=''*f=mypct.
,
var3=''*var2=''
/box="M";
run;
proc tabulate data=test;
title '2) PROC TABULATE with row=float';
title2 'ROW=FLOAT suppresses the unwanted empty cells in the row header area';
class var1 var2 var3 var4 var6 var7;
var var5 var8;
table var5='NB1' *sum=''
var8='NB2'*sum=''
var8=''*var1=''*reppctsum=''*f=mypct.
,
var3=''*var2=''
/box="M" row=float;
run;
title; footnote;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.