Working with SAS Data Sets

Using the READ Statement with the VAR and INTO Clauses

Sometimes you want to have all of the numeric variables in the same matrix so that you can determine correlations. Use the READ statement with the INTO clause and the VAR clause to read the variables listed in the VAR clause into the single matrix named in the INTO clause. Each variable in the VAR clause becomes a column of the target matrix. If there are p variables in the VAR clause and n observations are processed, the target matrix in the INTO clause is an n x p matrix.

The following statement creates a matrix x containing the numeric variables of the CLASS data set. Notice the use of the keyword _NUM_ in the VAR clause to specify that all numeric variables be read.

  
    > read all var _num_ into x; 
    > print x; 
  
                          X 
                         11      51.3      50.5 
                         11      57.5        85 
                         12      57.3        83 
                         12      59.8      84.5 
                         12        59      99.5 
                         12      56.3        77 
                         12      64.8       128 
                         13      56.5        84 
                         13      65.3        98 
                         13      62.5        84 
                         14      62.8     102.5 
                         14      63.5     102.5 
                         14        69     112.5 
                         14      64.3        90 
                         15      62.5     112.5 
                         15      66.5       112 
                         15        67       133 
                         15      66.5       112 
                         16        72       150
 

Previous Page | Next Page | Top of Page