Working with SAS Data Sets

Using the CREATE Statement with the VAR Clause

You can use a VAR clause with the CREATE statement to select the variables you want to include in the new data set. In the previous example, the new data set RATIO had one variable. If you want to create a similar data set but include the second variable NAME, you use the VAR clause. You could not do this with the FROM option because the variable HTWT is numeric and the variable NAME is character. The following statements create a new data set RATIO2 having the variables NAME and HTWT:

  
    > create ratio2 var{name htwt}; 
    > append; 
    > show contents; 
  
                 VAR NAME   TYPE   SIZE 
                 NAME       CHAR     8 
                 HTWT       NUM      8 
                 Number of Variables:    2 
                 Number of Observations: 18 
  
    > close ratio2;
 
Notice that now the variable NAME is in the data set.

Previous Page | Next Page | Top of Page