Thursday, June 23, 2011

PROC CONTENTS and Set Options for Outputs

libname mozart 'C:\books\learning';
data mozart.test_scores;
    length ID $ 3 ;
    input ID $ Score1-Score3 ;
    datalines;
    1 90 95 98
    2 78 77 75
    3 88 91 92

    run;
title "The Descriptor Portion of Data Set TEST_SCORES";
proc contents data = Mozart.test_scores;
run;

proc datasets;      
contents data=Mozart.test_scores;
run;
/*variable in creation order*/
title "The Descriptor Portion of Data Set TEST_scores";
proc contents data = Mozart.test_scores varnum;
run;

title "Listing All the SAS Data Sets in a Library";
proc contents data = Mozart._all_ nods;
run;

proc contents data=Mozart.Sales;
run;

/* Using a SAS data set as in put to a DATA step*/
data new;
    set mozart.test_scores;
    AveScore = mean(of score1-score3);
    run;
title "Listing of Data Set NEW";
proc print data = new;
    var ID Score1-Score3 AveScore;
    run;

options nonumber nodate;
proc print data = new;
    var ID Score1-Score3 AveScore;
    run;
/*options nodate pageno=3;*/

/* The PAGESIZE= option specifies how many lines each page of output contains. In the following
example, each page of the output that the PRINT procedure produces contains 15 lines (including
those used by the title, date, and so on).
    options pageno=1 pagesize=15;*/

/*  The LINESIZE= option specifies the width of the print line for your procedure output and log.
Observations that do not fit within the line size continue on a different line.

    options pageno=1 linesize=64;*/

/*using FIRSTOBS= and OBS= for Specific Data Sets 
    OBS indicates row variables*/
options firstobs=1 obs=2;
proc print data=new;
run;
/*specifying FIRSTOBS =  and OBS= as data set options*/
options firstobs=1 obs=2;
proc print data=new(firstobs=1 obs=3);
run;

/*The OPTIONS Procedure displays the current setting of one or all SAS system options
The results are displayed in the log*/
proc options;
run;