Working with SAS Data Sets


Use the CREATE Statement with the VAR Clause

You can use a VAR clause with the CREATE statement to select the variables that you want to include in the new data set.

The syntax is as follows:

  • CREATE SAS-data-set <VAR operand> ;

In the previous example, the new data set Ratio had one variable. You can use the VAR clause to create a similar data set to contain both HWRatio and Name. Notice that the variable HWRatio is numeric and the variable Name is character. Consequently, these two variables cannot coexist in a single matrix. The following statements create a new data set, Ratio2, to contain the variables Name and HWRatio:

create Ratio2 var {"Name" "HWRatio"};
append;
show contents;
close Ratio2;

Figure 7.19: New Data Set from Variables

DATASET : WORK.RATIO2.DATA                                                      
                                                                                
 VARIABLE                          TYPE  SIZE                                   
 --------------------------------  ----  ----                                   
 Name                              char     8                                   
 HWRatio                           num      8                                   
                                                                                
Number of Variables   : 2                                                       
Number of Observations: 19