Previous Page | Next Page

The DATASETS Procedure

Example 2: 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 does the following actions:


Program

 Note about code
options pagesize=60 linesize=80 nodate pageno=1 source;
LIBNAME dest1 'SAS-library-1';
LIBNAME dest2 'SAS-library-2';
LIBNAME health 'SAS-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 test2 vision weight;
quit;

SAS Log

117    options pagesize=60 linesize=80 nodate pageno=1 source;
118  LIBNAME dest1 'c:\Documents and Settings\mydir\My
118! Documents\procdatasets\dest1';
NOTE: Libref DEST1 was successfully assigned as follows:
      Engine:        V9
      Physical Name: c:\Documents and Settings\mydir\My
      Documents\procdatasets\dest1
119  LIBNAME dest2 'c:\Documents and Settings\mydir\My
119! Documents\procdatasets\dest2';
NOTE: Libref DEST2 was successfully assigned as follows:
      Engine:        V9
      Physical Name: c:\Documents and Settings\mydir\My
      Documents\procdatasets\dest2
120  LIBNAME health 'c:\Documents and Settings\mydir\My
120! Documents\procdatasets\health';
NOTE: Libref HEALTH was successfully assigned as follows:
      Engine:        V9
      Physical Name: c:\Documents and Settings\mydir\My
      Documents\procdatasets\health


121  proc datasets library=health details;
                                   Directory

Libref         HEALTH
Engine         V9
Physical Name  \myfiles\health
Filename       \myfiles\health



                     Member   Obs, Entries
        #  Name      Type      or Indexes   Vars  Label

        1  A1        CATALOG       23
        2  ALL       DATA          23        17
        3  BODYFAT   DATA           1         2
        4  CONFOUND  DATA           8         4
        5  CORONARY  DATA          39         4
        6  DRUG1     DATA           6         2   JAN2005 DATA
        7  DRUG2     DATA          13         2   MAY2005 DATA
        8  DRUG3     DATA          11         2   JUL2005 DATA
        9  DRUG4     DATA           7         2   JAN2002 DATA
       10  DRUG5     DATA           1         2   JUL2002 DATA
       11  ETEST1    CATALOG        1
       12  ETEST2    CATALOG        1
       13  ETEST3    CATALOG        1
       14  ETEST4    CATALOG        1
       15  ETEST5    CATALOG        1
       16  ETESTS    CATALOG        1
       17  FORMATS   CATALOG        6
       18  GROUP     DATA         148        11
       19  GRPOUT    DATA          11        40
       20  INFANT    DATA         149         6
       21  MLSCL     DATA          32         4   Multiple Sclerosis Data
       22  NAMES     DATA           7         4
       23  OXYGEN    DATA          31         7
       24  PERSONL   DATA         148        11
       25  PHARM     DATA           6         3   Sugar Study
       26  POINTS    DATA           6         6
       27  RESULTS   DATA          10         5
       28  SLEEP     DATA         108         6
       29  SPDATA    VIEW           .         2
       30  TEST2     DATA          15         5
       31  TRAIN     DATA           7         2
       32  VISION    DATA          16         3
       33  WEIGHT    DATA          83        13   California Results
       34  WGHT      DATA          83        13

                          File
                     #    Size  Last Modified

                     1   62464  07Mar05:14:36:20
                     2   13312  12Sep07:13:57:48
                     3    5120  12Sep07:13:57:48
                     4    5120  12Sep07:13:57:48
                     5    5120  12Sep07:13:57:48
                     6    5120  12Sep07:13:57:49
                     7    5120  12Sep07:13:57:49
                     8    5120  12Sep07:13:57:49
                     9    5120  12Sep07:13:57:49
                    10    5120  12Sep07:13:57:49
                    11   17408  04Jan02:14:20:16
                    12   17408  04Jan02:14:20:16
                    13   17408  04Jan02:14:20:16
                    14   17408  04Jan02:14:20:16
                    15   17408  04Jan02:14:20:16
                    16   17408  24Mar05:16:12:20
                    17   17408  24Mar05:16:12:20
                    18   25600  12Sep07:13:57:50
                    19   17408  24Mar05:15:33:31
                    20   17408  12Sep07:13:57:51
                    21    5120  12Sep07:13:57:50
                    22    5120  12Sep07:13:57:50
                    23    9216  12Sep07:13:57:50
                    24   25600  12Sep07:13:57:51
                    25    5120  12Sep07:13:57:51
                    26    5120  12Sep07:13:57:51
                    27    5120  12Sep07:13:57:52
                    28    9216  12Sep07:13:57:52
                    29    5120  24Mar05:16:12:21
                    30    5120  12Sep07:13:57:52
                    31    5120  12Sep07:13:57:53
                    32    5120  12Sep07:13:57:53
                    33   13312  12Sep07:13:57:53
                    34   13312  12Sep07:13:57:53
122  delete tension a2(mt=catalog);
123  change a1=postdrug;
124  exchange weight=bodyfat;
NOTE: Changing the name HEALTH.A1 to HEALTH.POSTDRUG (memtype=CATALOG).
NOTE: Exchanging the names HEALTH.WEIGHT and HEALTH.BODYFAT (memtype=DATA).
125  copy out=dest1 move memtype=view;
126  select spdata;
127
128  select etest1-etest5 / memtype=catalog;
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).
129  copy out=dest2;
130  exclude d: mlscl oxygen test2 vision weight;
131  quit;

NOTE: Copying HEALTH.ALL to DEST2.ALL (memtype=DATA).
NOTE: There were 23 observations read from the data set HEALTH.ALL.
NOTE: The data set DEST2.ALL has 23 observations and 17 variables.
NOTE: Copying HEALTH.BODYFAT to DEST2.BODYFAT (memtype=DATA).
NOTE: There were 83 observations read from the data set HEALTH.BODYFAT.
NOTE: The data set DEST2.BODYFAT has 83 observations and 13 variables.
NOTE: Copying HEALTH.CONFOUND to DEST2.CONFOUND (memtype=DATA).
NOTE: There were 8 observations read from the data set HEALTH.CONFOUND.
NOTE: The data set DEST2.CONFOUND has 8 observations and 4 variables.
NOTE: Copying HEALTH.CORONARY to DEST2.CORONARY (memtype=DATA).
NOTE: There were 39 observations read from the data set HEALTH.CORONARY.
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: There were 148 observations read from the data set HEALTH.GROUP.
NOTE: The data set DEST2.GROUP has 148 observations and 11 variables.
NOTE: Copying HEALTH.GRPOUT to DEST2.GRPOUT (memtype=DATA).
NOTE: There were 11 observations read from the data set HEALTH.GRPOUT.
NOTE: The data set DEST2.GRPOUT has 11 observations and 40 variables.
NOTE: Copying HEALTH.INFANT to DEST2.INFANT (memtype=DATA).
NOTE: There were 149 observations read from the data set HEALTH.INFANT.
NOTE: The data set DEST2.INFANT has 149 observations and 6 variables.
NOTE: Copying HEALTH.NAMES to DEST2.NAMES (memtype=DATA).
NOTE: There were 7 observations read from the data set HEALTH.NAMES.
NOTE: The data set DEST2.NAMES has 7 observations and 4 variables.
NOTE: Copying HEALTH.PERSONL to DEST2.PERSONL (memtype=DATA).
NOTE: There were 148 observations read from the data set HEALTH.PERSONL.
NOTE: The data set DEST2.PERSONL has 148 observations and 11 variables.
NOTE: Copying HEALTH.PHARM to DEST2.PHARM (memtype=DATA).
NOTE: There were 6 observations read from the data set HEALTH.PHARM.
NOTE: The data set DEST2.PHARM has 6 observations and 3 variables.
NOTE: Copying HEALTH.POINTS to DEST2.POINTS (memtype=DATA).
NOTE: There were 6 observations read from the data set HEALTH.POINTS.
NOTE: The data set DEST2.POINTS has 6 observations and 6 variables.
NOTE: Copying HEALTH.POSTDRUG to DEST2.POSTDRUG (memtype=CATALOG).
NOTE: Copying HEALTH.RESULTS to DEST2.RESULTS (memtype=DATA).
NOTE: There were 10 observations read from the data set HEALTH.RESULTS.
NOTE: The data set DEST2.RESULTS has 10 observations and 5 variables.
NOTE: Copying HEALTH.SLEEP to DEST2.SLEEP (memtype=DATA).
NOTE: There were 108 observations read from the data set HEALTH.SLEEP.
NOTE: The data set DEST2.SLEEP has 108 observations and 6 variables.
NOTE: Copying HEALTH.TRAIN to DEST2.TRAIN (memtype=DATA).
NOTE: There were 7 observations read from the data set HEALTH.TRAIN.
NOTE: The data set DEST2.TRAIN has 7 observations and 2 variables.
NOTE: Copying HEALTH.WGHT to DEST2.WGHT (memtype=DATA).
NOTE: There were 83 observations read from the data set HEALTH.WGHT.
NOTE: The data set DEST2.WGHT has 83 observations and 13 variables.
NOTE: PROCEDURE DATASETS used (Total process time):
      real time           44.04 seconds
      cpu time            0.60 seconds

Previous Page | Next Page | Top of Page