Also order of definition in the value section of proc format statements makes a difference in output.
Please see an example below.
/* a further example with multilabel formats */
/* the indents are just to show the desired levels */
/* I think that the order the statements occur in */
/* format may have an affect based on the options */
/* in Proc Tabulate. The spaces in the label are */
/* actually character 255 (Alt+255 on numeric pad) */
/* Motor and Water are in that order to show that */
/* the output order is sorted in the manner we want*/
/* not by the text of the responses */
/* (at least one case below ) */
proc format library=work;
value accidentl (multilabel notsorted)
1-5 = 'Accidents'
1-3 = ' Transport accidents'
1 = ' Motor vehicle accidents'
2 = ' Water, air, and space'
3 = ' Other land transport accidents'
4-5 = ' Nontransport accidents'
5 = ' Fishing'
;
value accidentr (multilabel notsorted)
1-5 = 'Accidents'
1-3 = ' Transport accidents'
4-5 = ' Nontransport accidents'
1 = ' Motor vehicle accidents'
2 = ' Water, air, and space'
3 = ' Other land transport accidents'
5 = ' Fishing'
;
value mf
1 = "Male"
2 = "Female"
;
run;
/* populate a dataset to display */
/* This specifically does NOT generate any data for FISHING above*/
/* to display the behavior of the options below in those cases. */
data junk;
do i=1 to 50;
type = round(4*ranuni(1234)+.5);
sex = round(2*ranuni(3455)+.5);
output;
end;
run;
/* Notice that before we get here the data is NOT sorted */
/* in any manner!!!! */
proc tabulate data=junk order=data;
class type / mlf PRELOADFMT;
class sex;
table type=' ', all='Total'*n=' '*f=comma9. sex=' '*n=' '*f=comma8.
/rts=35 printmiss misstext='0';
format type accidentl. sex mf.;
title 'Option Order=Data Preloadfmt Printmiss Misstext=0 format accidentl';
run;
proc tabulate data=junk order=data;
class type / mlf PRELOADFMT;
class sex;
table type=' ', all='Total'*n=' '*f=comma9. sex=' '*n=' '*f=comma8.
/rts=35 printmiss misstext='0';
format type accidentr. sex mf.;
title 'Option Order=Data Preloadfmt Printmiss Misstext=0 format accidentr';
run;
title;
... View more