• Home
  • Profile
  • Papers
  • SAS programs

SAS programs
  • Write catalog content to text file
  • Create a document per format encountered
  • Dataset desciption of all dataset in the library
  • Effective questionnaire processing with Arrays
  • Proc transpose
  • Proc SQL where clause
  • Proc SQL dataset maintenance
  • Execute a macro with the value from a dataset observation
  • Change a format stored in the formats catalog
  • Create an empty dataset
Home Create an empty dataset

Create an empty dataset

[Download] [Print]
%******************************************************************************;
%** http://www.info-net.nl                                                   **;
%******************************************************************************;
%* Topic         : SAS Base                                                   *;
%* Program       : Create an empty dataset                                    *;
%* Author        : Raymond Ebben                                              *;
%* Location      : http://www.info-net.nl/index/sas-coding/sas-base           *;
%* Date          : January 2006                                               *;
%* Version       : 1.0                                                        *;
%* Description   : This program illustrates three examples of how to create   *;
%*                 an empty dataset                                           *;
%******************************************************************************;
%* In datasets   : None                                                       *;
%* In macrovars  : None                                                       *;
%* In files      : None                                                       *;
%* Out datasets  : work.newdataset                                            *;
%* Out macrovars : None                                                       *;
%* Out files     : None                                                       *;
%******************************************************************************;
%** Version control                                                          **;
%******************************************************************************;
%* Mod * Ver. * Date      *  Description                                      *;
%******************************************************************************;
%******************************************************************************;
 
%******************************************************************************;
%* Create an empty dataset using the SAS dataset                              *;
%******************************************************************************;
data work.newdataset;
  length numvar1 8 name $10 date date2 8;
  format date
         date2 date9.;
  label numvar1 ='Num. variable                  '
        name    ='Char. variable with length 20  '
        date    ='Num. variable with date9 format'
        date2   ='Num. variable with date9 format';
  /* Make sure that no records will be outputted */
  stop;
run;
 
%******************************************************************************;
%* Create an empty dataset using the structure of an existing dataset as a    *;
%* template                                                                   *;
%******************************************************************************;
data work.newdataset;
  set sashelp.class;
  /* Make sure that no records will be outputted */
  stop;
run;
 
%******************************************************************************;
%* Create an empty dataset using proc sql to set up a structure               *;
%******************************************************************************;
proc sql noprint;
  create table work.newdataset
  (
  /*varname type size format        label                                 */
    numvar1 num                     label='Num. variable                  ',
    name    char (10)               label='Char. variable with length 20  ',
    date    num       format=date9. label='Num. variable with date9 format',
    date2   num       format=date9. label='Num. variable with date9 format'
   );
quit;
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
 
 

© 2010 Raymond Ebben, expert SAS consultant and programmer, Netherlands All Rights Reserved.