CONTENTS Procedure

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

Features:
CONTENTS statement options::
ORDER=
COLLATE
CASECOLLATE
IGNORECASE
VARNUM

Details

The ORDER= options prints a list of variables in a specified order.

Program

options nonotes nodate nonumber nocenter formdlim  ='-';

libname contents 'c:\proccontents';

data contents.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;
%let mydata=contents.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;
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;  

Program Description

Set up the data set.
options nonotes nodate nonumber nocenter formdlim  ='-';

libname contents 'c:\proccontents';

data contents.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;
To produce PROC CONTENTS output for a data set of your choice, change data set name to MYDATA.
%let mydata=contents.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;
The name of the ODS output object is different when the varnum option is used.
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;  

Using the COLLATE and CASECOLLATE Options

The following output shows the results of the ORDER= default, the COLLATE option, and the CASECOLLATE option.
Using the COLLATE and CASECOLLATE Options
The following output shows the results of the ORDER= default, IGNORECASE option, and VARNUM option.
Results of Using the IGNORECASE and VARNUM Options
Results of Using the IGNORECASE and VARNUM Options