Previous Page | Next Page

SAS Component Language Dictionary

NEW



Defines a new SAS table interactively
Category: SAS Table

Syntax
Details
Examples
Example 1: Creating a SAS Table from a Model Table
Example 2: Creating a SAS Table from a User Definition
See Also

Syntax

CALL NEW(table-name,model-table,num-row, display-window);

table-name

is the SAS table to be created, specified as <libref.>member. The default library, USER, is used if libref is omitted. If a null string ('') is specified for table-name, then the DATAn naming convention is used to create a table in the USER library.

Type: Character

model-table

is an existing SAS table after which the new SAS table is to be modeled. Use a null string ('') as a placeholder if you do not want to specify a model table.

Type: Character

num-row

is the number of initial rows for the new SAS table. This value must be equal to or greater than 0. All columns in all rows initially contain missing values. The value for num-row cannot be a missing value.

Type: Numeric

display-window

specifies whether the NEW window is displayed so that column definitions for the new SAS table can be edited before the table is created:

'Y'

displays the NEW window to allow editing of the column names and attributes before the new SAS table is created. (This is the default.)

'N'

does not display the NEW window. The column definitions in the new SAS table will be an exact replica of those in the model table. A value must also be supplied for model-table.

Type: Character


Details

NEW creates a new blank SAS table. However, it does not replace an existing table.

CAUTION:
Specifying an existing SAS table for table-name causes a program halt.

To prevent the program halt, use EXIST to determine whether the table already exists, DELETE to delete the table, and CALL NEW to create a new table with the same name.  [cautionend]

By default, the routine opens the NEW window to enable a user to interactively define the names and attributes of the columns in the new SAS table. The NEW window that this routine opens is the same as the window that is displayed when the NEW= option is used with the PROC FSEDIT or PROC FSVIEW statement.

You can specify model-table so that all the names and attributes of the model are automatically copied to the new table. (Only the column names and column attributes of the model table are copied, not the values that it contains.) When you specify a model table, you can use display-window to bypass the NEW window and create the new table with the same column names and attributes as the model table (specify 'N' for the display-window parameter). Open the NEW window only if you want to enable users to alter the column names and attributes before the new table is created.

Use num-row to specify how many blank rows to create for the new SAS table. All columns in all rows of the new table initially contain missing values.


Examples


Example 1: Creating a SAS Table from a Model Table

Create a new SAS table with a name that the user supplies in the field for the window variable TABLE. Before attempting to create the table, determine whether a SAS table with the specified name already exists. If so, issue a message on the application window's message line. The new table is modeled after the existing table MODEL.A, and the user is not given the opportunity to modify the column definitions (the NEW window is not opened). The new table is created with ten blank rows.

if (exist(table)) then
 _msg_='SAS table '||table||' already exists.';
else
   do;
      call new(table,'model.a',10,'n');
      _msg_='SAS table '||table||' has been created.';
   end;


Example 2: Creating a SAS Table from a User Definition

Create a new SAS table with a name that the user supplies in the field for the window variable TABLE. These statements display the NEW window for the user to define the columns in the table. No model table is used.

if (exist(table)) then
  _msg_='SAS table '||table||' already exists.';
else
   do;
      call new(table,' ',1,'y');
      _msg_='SAS table '||table||' has been created.';
   end;


See Also

FSEDIT

FSVIEW

NEWVAR

OPEN

Previous Page | Next Page | Top of Page