Return to Homepage

Goto the Tip of the Month Archive

Other interesting pages ...
LinkedIn Profile
SAS Cheat Sheet
Useful SAS Code
Full SAS Example
Basic Statistics
Contact Information

SAS Tip of the Month
January 2014
(for SAS and WPS)

So you have some new data and you just want to see there is more observations than last time -- maybe some thought the the data was smaller or the same?

Here is a little piece of code that will help -- I have two directories of data, both referenced by the libnames TUAI_NEW and TUAI_OLD:

   *Setup and set libnames for the old and new data;
   options date;
   libname TUAI_OLD "C:\TUAI\DATA\OLDDATA";
   libname TUAI_NEW "C:\TUAI\DATA\OLDNEW";
   run;
   
   *Get Dictionary information from VTABLE in the SASHELP directory for the two libraries
    keeping only the number of observations;
   proc sort data=sashelp.vtable out=_old0 (keep=memname nobs);
      by memname;
      where libname='TUAI_OLD';
   proc sort data=sashelp.vtable out=_new0 (keep=memname nobs);
      by memname;
      where libname='TUAI_NEW';
   run;
   
   *Merge the two sets of information renaming the number of observations in the
    TUAI_NEW library;
   data _all0;
      merge _old0 _new0 (rename=(nobs=_nobs));
      by memname;
   run;
   
   *Use PROC PRINT as a tool to generate the report;
   title1 "Quick Compare of Old Data vs New Data";
   proc print data=_all0 label noobs;
      var memname nobs _nobs;
      label memname='Dataset'
            nobs='Obs in Old Data'
            _nobs='Obs in New Data';
   run;

This piece of code will write a quick report of the number of observations of each dataset in the two libraries referenced.

Hope this is useful. See you next month.

________________________________
Updated January 2, 2014