Previous Page | Next Page

The DATASETS Procedure

Example 10: Using the ORDER= Option with the CONTENTS Statement


Procedure features:

CONTENTS statement options:

ORDER=

COLLATE

CASECOLLATE

IGNORECASE

VARNUM



Program

 Note about code
options nonotes nodate nonumber nocenter formdlim  ='-';
     
data test;
   d=2;
   b001 =1;
   b002 =2;
   b003 =3;
   b001z=1;
   B001a=2;
   CaSeSeNsItIvE2=9;
   CASESENSITIVE3=9;
   D=2;
   casesensitive1=9;
   CaSeSeNsItIvE1a=9;
   d001z=1;   
   CASESENSITIVE1C=9;
   D001a=2;   
   casesensitive1b=9;  
   A =1;
   a002 =2;
   a =3;
   a001z=1;
   A001a=2;
  
run;
 Note about code
%let mydata=WORK.test;  
    
ods output Variables=var1(keep=Num Variable);
ods listing close;

proc contents data=&mydata;
run;
  
ods listing;
    title "Default options";

proc print data=var1 noobs;
run; 
  
ods output Variables=var2(keep=Num Variable);
ods listing close;

proc contents order=collate data=&mydata; 
run;
  
ods listing;
    title "order=collate option";

proc print data=var2 noobs;
run;  
  
ods output Variables=var3(keep=Num Variable);
ods listing close;

proc contents order=casecollate data=&mydata; 
run;
  
ods listing;
    title "order=casecollate option";
  
proc print data=var3 noobs;
run;    
  
ods output Variables=var4(keep=Num Variable);
ods listing close;
  
proc contents order=ignorecase data=&mydata; 
run;
  
ods listing;
    title "order=ignorecase option";
  
proc print data=var4 noobs;
run;      

 Note about code
ods output Position=var5(keep=Num Variable);
ods listing close;

proc contents data=&mydata varnum;
run;

ods listing;
    title "varnum option";

proc print data=var5 noobs;
run;  

Results

The following table shows the results of the ORDER= default, the COLLATE option, and the CASECOLLATE option:

Using the COLLATE and CASECOLLATE Options
default COLLATE CASECOLLATE
Num    Variable

15     A              
18     A001a          
 6     B001a          
 8     CASESENSITIVE3 
12     CASESENSITIVE1C
 7     CaSeSeNsItIvE2 
10     CaSeSeNsItIvE1a
13     D001a          
16     a002           
17     a001z          
 2     b001           
 3     b002           
 4     b003           
 5     b001z          
 9     casesensitive1 
14     casesensitive1b
 1     d              
11     d001z          
Num    Variable

15     A              
18     A001a          
 6     B001a          
12     CASESENSITIVE1C
 8     CASESENSITIVE3 
10     CaSeSeNsItIvE1a
 7     CaSeSeNsItIvE2 
13     D001a          
17     a001z          
16     a002           
 2     b001           
 5     b001z          
 3     b002           
 4     b003           
 9     casesensitive1 
14     casesensitive1b
 1     d              
11     d001z          
Num    Variable

15     A              
18     A001a          
17     a001z          
16     a002           
 2     b001           
 6     B001a          
 5     b001z          
 3     b002           
 4     b003           
 9     casesensitive1 
10     CaSeSeNsItIvE1a
14     casesensitive1b
12     CASESENSITIVE1C
 7     CaSeSeNsItIvE2 
 8     CASESENSITIVE3 
 1     d              
13     D001a          
11     d001z       

The following table shows the results of the ORDER= default, IGNORECASE option, and VARNUM option.

Results of Using the IGNORECASE and VARNUM Options
default IGNORECASE VARNUM
Num    Variable

15     A              
18     A001a          
 6     B001a          
 8     CASESENSITIVE3 
12     CASESENSITIVE1C
 7     CaSeSeNsItIvE2 
10     CaSeSeNsItIvE1a
13     D001a          
16     a002           
17     a001z          
 2     b001           
 3     b002           
 4     b003           
 5     b001z          
 9     casesensitive1 
14     casesensitive1b
 1     d              
11     d001z          
Num    Variable

15     A              
16     a002           
18     A001a          
17     a001z          
 2     b001           
 3     b002           
 4     b003           
 6     B001a          
 5     b001z          
 9     casesensitive1 
 7     CaSeSeNsItIvE2 
 8     CASESENSITIVE3 
10     CaSeSeNsItIvE1a
14     casesensitive1b
12     CASESENSITIVE1C
 1     d              
13     D001a          
11     d001z            
Num    Variable

 1     d              
 2     b001           
 3     b002           
 4     b003           
 5     b001z          
 6     B001a          
 7     CaSeSeNsItIvE2 
 8     CASESENSITIVE3 
 9     casesensitive1 
10     CaSeSeNsItIvE1a
11     d001z          
12     CASESENSITIVE1C
13     D001a          
14     casesensitive1b
15     A              
16     a002           
17     a001z          
18     A001a           

Previous Page | Next Page | Top of Page