Chapter Contents

Previous

Next
The DATASETS Procedure

Example 1: Manipulating SAS Files


Procedure features:
PROC DATASETS statement options:
DETAILS
LIBRARY=
CHANGE statement
COPY statement options:
MEMTYPE
MOVE
OUT=
DELETE statement option:
MEMTYPE=
EXCHANGE statement
EXCLUDE statement
SELECT statement option:
MEMTYPE=

This example


Program
 Note about code
options pagesize=40 linesize=132 nodate pageno=1 source;

libname dest1 'SAS-data-library-1';
libname dest2 'SAS-data-library-2';
libname health 'SAS-data-library-3';
 Note about code
proc datasets library=health details;


 Note about code
   delete tension a2(mt=catalog);
   change a1=postdrug;
   exchange weight=bodyfat;





 Note about code
   copy out=dest1 move memtype=view;


 Note about code
      select spdata;


 Note about code
      select etest1-etest5 / memtype=catalog;


 Note about code
   copy out=dest2;
      exclude d: mlscl oxygen source test2 vision weight;
quit;


SAS Log
 Note about figure
      cpu time            0.00 seconds
      
1   
2   libname dest1
3   'SAS-data-library';
NOTE: Libref DEST1 was successfully assigned as follows: 
      Engine:        V8 
      Physical Name: UNIX-path
4   libname dest2
5   'SAS-data-library';
NOTE: Libref DEST2 was successfully assigned as follows: 
      Engine:        V8 
      Physical Name: UNIX-path 
6   libname health
7   'SAS-data-library ';
NOTE: Libref HEALTH was successfully assigned as follows: 
      Engine:        V8 
      Physical Name: UNIX-path  
      
17   proc datasets library=health details;
                                                        -----Directory-----

                    Libref:            HEALTH                                                                  
                    Engine:            V8                                                                      
                    Physical Name:     UNIX-path                                                    
                    File Name:         UNIX-path                                                    
                    Inode Number:      inode-number                                                 
                    Access Permission: rwxr-xr-x                                                               
                    Owner Name:        UNIX-user                                                    
                    File Size (bytes): 4096                                                                    
                                         Obs, Entries                                   File
                   #  Name      Memtype   or Indexes   Vars  Label                      size  Last modified
                  -----------------------------------------------------------------------------------------------
                   1  A1        CATALOG       23                                       69632   09FEB1999:10:42:10
                   2  A2        CATALOG        1                                       24576   09FEB1999:10:42:11
                   3  ALL       DATA          23        17                             17408   09FEB1999:10:42:11
                   4  BODYFAT   DATA           1         2                             12288   09FEB1999:10:42:11
                   5  CONFOUND  DATA           8         4                             12288   09FEB1999:10:42:11
                   6  CORONARY  DATA          39         4                             12288   09FEB1999:10:42:11
                   7  DRUG1     DATA           6         2   JAN95 Data                12288   09FEB1999:10:42:11
                   8  DRUG2     DATA          13         2   MAY95 Data                12288   09FEB1999:10:42:11
                   9  DRUG3     DATA          11         2   JUL95 Data                12288   09FEB1999:10:42:11
                  10  DRUG4     DATA           7         2   JAN92 Data                12288   09FEB1999:10:42:11
                  11  DRUG5     DATA           1         2   JUL92 Data                12288   09FEB1999:10:42:11
                  12  ETEST1    CATALOG        1                                       24576   09FEB1999:10:42:11
                  13  ETEST2    CATALOG        1                                       24576   09FEB1999:10:42:12
                  14  ETEST3    CATALOG        1                                       24576   09FEB1999:10:42:12
                  15  ETEST4    CATALOG        1                                       24576   09FEB1999:10:42:12
                  16  ETEST5    CATALOG        1                                       24576   09FEB1999:10:42:12
                  17  ETESTS    CATALOG        1                                       24576   09FEB1999:10:42:12
                  18  FORMATS   CATALOG        6                                       24576   09FEB1999:10:42:12
                  19  GROUP     DATA         148        11                             32768   09FEB1999:10:42:13
                  20  GRPOUT    DATA          11        40                             24576   29JAN1999:13:38:22
                  21  INFANT    DATA         149         6                             23552   18JAN1999:14:08:42
                  22  MLSCL     DATA          32         4   Multiple Sclerosis Data   12288   09FEB1999:10:42:13
                  23  NAMES     DATA           7         4                             12288   09FEB1999:10:42:13
                  24  OXYGEN    DATA          31         7                             13312   09FEB1999:10:42:13
                  25  PERSONL   DATA         148        11                             32768   09FEB1999:10:42:13
                  26  PHARM     DATA           6         3   Sugar Study               12288   09FEB1999:10:42:13
                  27  POINTS    DATA           6         6                             12288   09FEB1999:10:42:13
                  28  PRENAT    DATA         149         6                             23552   09FEB1999:10:42:13
                  29  RESULTS   DATA          10         5                             12288   09FEB1999:10:42:13
                  30  SLEEP     DATA         108         6                             16384   09FEB1999:10:42:13
                  31  SOURCE    PROGRAM                                                16384   09FEB1999:10:42:13
                  32  SPDATA    VIEW           .         2                             12288   09FEB1999:10:42:14
                  33  SUR       DATA           3         6                             12288   18JAN1999:14:08:44
                  34  SYNDROME  DATA          46         8                             16384   09FEB1999:10:42:14
                  35  TENSION   DATA           4         3                             12288   09FEB1999:10:42:14
                  36  TEST2     DATA          15         5                             12288   09FEB1999:10:42:14
                  37  TRAIN     DATA           7         2                             12288   09FEB1999:10:42:14
                  38  VISION    DATA          16         3                             12288   09FEB1999:10:42:14
                  39  WEIGHT    DATA          83        13   California Results        26624   09FEB1999:10:42:14
                  40  WGHT      DATA          83        13   California Results        26624   09FEB1999:10:42:14
19      delete tension a2(mt=catalog);
20      change a1=postdrug;
21      exchange weight=bodyfat;
NOTE: Deleting HEALTH.TENSION (memtype=DATA).
NOTE: Deleting HEALTH.A2 (memtype=CATALOG).
NOTE: Changing the name HEALTH.A1 to HEALTH.POSTDRUG (memtype=CATALOG).
NOTE: Exchanging the names HEALTH.WEIGHT and HEALTH.BODYFAT (memtype=DATA).
22      copy out=dest1 move memtype=view;
23   
24         select spdata;
25   
26         select etest1-etest5 / memtype=catalog;
27   
NOTE: Moving HEALTH.SPDATA to DEST1.SPDATA (memtype=VIEW).
NOTE: Moving HEALTH.ETEST1 to DEST1.ETEST1 (memtype=CATALOG).
NOTE: Moving HEALTH.ETEST2 to DEST1.ETEST2 (memtype=CATALOG).
NOTE: Moving HEALTH.ETEST3 to DEST1.ETEST3 (memtype=CATALOG).
NOTE: Moving HEALTH.ETEST4 to DEST1.ETEST4 (memtype=CATALOG).
NOTE: Moving HEALTH.ETEST5 to DEST1.ETEST5 (memtype=CATALOG).
28      copy out=dest2;
29         exclude d: mlscl oxygen source test2 vision weight;
30   quit;
NOTE: Copying HEALTH.ALL to DEST2.ALL (memtype=DATA).
NOTE: The data set DEST2.ALL has 23 observations and 17 variables.
NOTE: Copying HEALTH.BODYFAT to DEST2.BODYFAT (memtype=DATA).
NOTE: The data set DEST2.BODYFAT has 83 observations and 13 variables.
NOTE: Copying HEALTH.CONFOUND to DEST2.CONFOUND (memtype=DATA).
NOTE: The data set DEST2.CONFOUND has 8 observations and 4 variables.
NOTE: Copying HEALTH.CORONARY to DEST2.CORONARY (memtype=DATA).
NOTE: The data set DEST2.CORONARY has 39 observations and 4 variables.
NOTE: Copying HEALTH.ETESTS to DEST2.ETESTS (memtype=CATALOG).
NOTE: Copying HEALTH.FORMATS to DEST2.FORMATS (memtype=CATALOG).
NOTE: Copying HEALTH.GROUP to DEST2.GROUP (memtype=DATA).
NOTE: The data set DEST2.GROUP has 148 observations and 11 variables.
NOTE: Copying HEALTH.GRPOUT to DEST2.GRPOUT (memtype=DATA).
NOTE: The data set DEST2.GRPOUT has 11 observations and 40 variables.
NOTE: Copying HEALTH.INFANT to DEST2.INFANT (memtype=DATA).
NOTE: The data set DEST2.INFANT has 149 observations and 6 variables.
NOTE: Copying HEALTH.NAMES to DEST2.NAMES (memtype=DATA).
NOTE: The data set DEST2.NAMES has 7 observations and 4 variables.
NOTE: Copying HEALTH.PERSONL to DEST2.PERSONL (memtype=DATA).
NOTE: The data set DEST2.PERSONL has 148 observations and 11 variables.
NOTE: Copying HEALTH.PHARM to DEST2.PHARM (memtype=DATA).
NOTE: The data set DEST2.PHARM has 6 observations and 3 variables.
NOTE: Copying HEALTH.POINTS to DEST2.POINTS (memtype=DATA).
NOTE: The data set DEST2.POINTS has 6 observations and 6 variables.
NOTE: Copying HEALTH.POSTDRUG to DEST2.POSTDRUG (memtype=CATALOG).
NOTE: Copying HEALTH.PRENAT to DEST2.PRENAT (memtype=DATA).
NOTE: The data set DEST2.PRENAT has 149 observations and 6 variables.
NOTE: Copying HEALTH.RESULTS to DEST2.RESULTS (memtype=DATA).
NOTE: The data set DEST2.RESULTS has 10 observations and 5 variables.
NOTE: Copying HEALTH.SLEEP to DEST2.SLEEP (memtype=DATA).
NOTE: The data set DEST2.SLEEP has 108 observations and 6 variables.
NOTE: Copying HEALTH.SUR to DEST2.SUR (memtype=DATA).
NOTE: The data set DEST2.SUR has 3 observations and 6 variables.
NOTE: Copying HEALTH.SYNDROME to DEST2.SYNDROME (memtype=DATA).
NOTE: The data set DEST2.SYNDROME has 46 observations and 8 variables.
NOTE: Copying HEALTH.TRAIN to DEST2.TRAIN (memtype=DATA).
NOTE: The data set DEST2.TRAIN has 7 observations and 2 variables.
NOTE: Copying HEALTH.WGHT to DEST2.WGHT (memtype=DATA).
NOTE: The data set DEST2.WGHT has 83 observations and 13 variables.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.