Displaying All Columns

You already know how to select specific columns for output by listing them in the SELECT statement. However, for some tasks, you find it useful to display all columns of a table concurrently. For example, before you create a complex query, you might want to see the contents of the table that you are working with.

Using SELECT *

To display all columns in the order in which they are stored in a table, use an asterisk (*) in the SELECT clause. All rows are displayed, by default, unless you limit or subset them.
The following SELECT step displays all columns and rows in the table Sasuser.Staffchanges, which lists all employees in a company who have had changes in their employment status.
proc sql;
   select *
      from sasuser.staffchanges;
As shown in the output, the table contains six columns and six rows.
Displaying All Columns and Rows in the Table Sasuser.Staffchanges

Using the FEEDBACK Option

When you specify SELECT *, you can also use the FEEDBACK option in the PROC SQL statement, which writes the expanded list of columns to the SAS log. For example, the PROC SQL query shown below contains the FEEDBACK option:
proc sql feedback;
   select *
      from sasuser.staffchanges;
This query produces the following feedback in the SAS log.
Table 2.1 SAS Log
202 proc sql feedback;
203 select *
204 from sasuser.staffchanges;
NOTE: Statement transforms to:

       select STAFFCHANGES.EmpID,
STAFFCHANGES.LastName, STAFFCHANGES.FirstName,
STAFFCHANGES.City, STAFFCHANGES.State,
STAFFCHANGES.PhoneNumber
          from SASUSER.STAFFCHANGES
The FEEDBACK option is a debugging tool that lets you see exactly what is being submitted to the SQL processor. The resulting message in the SAS log not only expands asterisks (*) into column lists, but it also resolves macro variables and places parentheses around expressions to show their order of evaluation.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.189.67