SAS Component Language Dictionary |
Category: | SAS Table |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
sysrc=NEWVAR(table-id,col-name,type<,length<,label
<,format<,informat>>>>); |
contains the return code for the operation:
0 | |
0 |
is the identifier that was assigned when the table was opened. If table-id is invalid, the program halts. The SAS table must be opened with an open mode of NEW.
is the name to assign to the new column. The name must be a valid SAS name.
specifies the data type of the new column:
'C' | |
'N' |
is the length of the new column. For a character column, this value can be between 1 and 32,767. For a numeric column, it can be between 3 and 8. On some systems, the minimum length can be 2.
is the label for the new column. This is a character string from 1 to 40 characters. If the label contains single quotes, use two single quotes for each of these internal single quotes, or surround the label with double quotes. Each set of two single quotes counts as one character.
is the format for the new column. This must be a valid SAS format name. Formats can be either defined by the user or supplied by SAS software. If not specified, SAS assigns a default format. If type is C, then a character format should be specified. Otherwise, a numeric format should be specified.
is the informat for the new column. This must be a valid SAS informat name. Informats can be either defined by the user or supplied by SAS software. If not specified, SAS assigns a default informat. If type is C, then a character informat should be specified. Otherwise, a numeric informat should be specified.
Details |
Opening an existing SAS table in NEW mode creates a new table that overwrites the old table. When the table is closed after using NEWVAR, the SAS table is created with zero rows. If the column name matches a column name that was defined for the table by a previous NEWVAR function, the new definition overrides the previous definition.
Example |
Open a new SAS table, MYDATA, in NEW mode, and then add the column AGE, which is numeric, and NAME, which is character. AGE has a length of 8, and NAME has a length of 20. The label of NAME is set to Last Name.
dsid=open('mydata','n'); rc=newvar(dsid,'age','n',8); rc=newvar(dsid,'name','c',20,'Last Name'); rc=close(dsid);
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.