As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Making Lists"

From sasCommunity
Jump to: navigation, search
m
Line 11: Line 11:
  
  
== List of SQL Dictionaries ==
+
== Review SQL Dictionaries ==
  
 
<pre>
 
<pre>
Line 19: Line 19:
 
           quit;
 
           quit;
 
</pre>
 
</pre>
 +
 +
== Make List of Files ==
 +
 +
== Make List of Folders ==
  
 
== Make List of Libnames ==
 
== Make List of Libnames ==

Revision as of 10:39, 18 August 2008

Making Lists for List Processing

autoexec.sas

These examples use a fileref SiteIncl which is allocated in an autoexec.

filename SiteIncl '.';
*or;
*filename SiteIncl 'C:\SAS-site\includes';


Review SQL Dictionaries

PROC SQL; describe table Dictionary.Dictionaries;
          select distinct Memname
          from   Dictionary.Dictionaries;
          quit;

Make List of Files

Make List of Folders

Make List of Libnames

PROC SQL; describe table Dictionary.Libnames;
          create table Work.ListLibnames as
          select *
          from   Dictionary.Libnames;
          quit;
* name: MlLibname-caller;
%Let MllPrefix = SAShelp;
%Include SiteIncl(MlLibnames);
Proc Print data = &SysLast.;
* name: MlLibnames;
PROC SQL; create table Work.ListLibnames as
          select *
          from   Dictionary.Libnames
          where  Libname like "%upcase(&MllPrefix.%";
          quit;

Make List of Memnames

Proc Contents

Proc SQL

* name: MlMemnames-caller;
%Let MlmLibname = Library;
%Let MlmLibname = SAShelp;
%Include SiteIncl(MlMemnames);

Proc Print data = &SysLast.;
* name: MlMemnames;
PROC SQL; create table Work.ListMemnames as
          select *
          from   Dictionary.Tables
          where  Libname eq "%upcase(&MlmLibname.)"
            and  MemType eq 'DATA';
          quit;

Make List of Names: Columns or Variables

Proc Contents

* name: MlNames-caller;
%Let MlnLibname = Library;
%Let MlnLibname = SAShelp;
%Let MlnMemname = _all_;
%Let MlnMemname = Class;
%Include SiteIncl(MlNames);
Proc Print data = &SysLast.;
* name: MlNames;
PROC Contents data   = &MlnLibname..&MlnMemnames.
                       noprint
              out    = Work.ListNames
             (keep   = Libname Memname Name Type Length Label VarNum
              where  = (MemType eq 'DATA') );

Proc SQL

* name: MlNames-caller;
%Let MlnLibname = Library;
%Let MlnLibname = SAShelp;
%Let MlnMemname = Class;
%Include SiteIncl(MlNames);
Proc Print data = &SysLast.;
* name: MlNames;
PROC SQL; create table Work.ListNames as
          select *
          from   Dictionary.Columns
          where  Libname eq "%upcase(&MlnLibname.)"
            and  Memname eq "%upcase(&MlnMemname.)"
            and  MemType eq 'DATA';
          quit;

Make List of Subsets

Proc Freq

* name: MlsFreq-caller;
%Let MlsLibname = Library;
%Let MlsLibname = SAShelp;
%Let MlsMemname = Class;
%Let MlsName    = Sex;
%Let MlsOut     = Work.ListSexes;
%Include SiteIncl(MlsFreq);
Proc Print data = &SysLast.;
* name: MlsFreq.sas;
Proc Freq data   = &MlsLibname..&MlsMemname.;
          tables   &MlsName.
                 / list missing noprint
             out = &MlsOut.;
run;

Proc Sort

* name: MlsSort-caller;
%Let MlsLibname = Library;
%Let MlsLibname = SAShelp;
%Let MlsMemname = Class;
%Let MlsNames   = Sex;
%Let MlsOut     = Work.ListSexes;
%Include SiteIncl(MlsSort);
Proc Print data = &SysLast.;
* name: MlsFreq.sas;
Proc Sort data = &MlsLibname..&MlsMemname.
         (keep = &MlsNames.)
          out  = &MlsOut.
                 nodupkey;
          by     &MlsNames.;
run;

Proc SQL

* name:;
select distinct ...;

Proc Summary

* name:;

Proc Univariate

* name:;


References

  • List Processing Basics
  • SmryEachVar
  • Writing Testing-Aware Programs

--macro maven == the radical programmer 11:13, 18 August 2008 (EDT)