SAS Component Language Dictionary |
Category: | SAS Table |
Syntax | |
Details | |
Examples | |
See Also |
Syntax |
selections=VARLIST(table-id,var-type,num-sel<,message <,autoclose<,sel-order<,exclude<,select>>>>>); |
contains one or more user selections from the list, or a blank if no selection is made. Multiple selections are separated by blanks. By default, selections is 200 bytes long. To accommodate values longer than 200 bytes, explicitly declare selections with a longer length.
is the identifier that was assigned when the table was opened. If table-id is invalid, the program halts.
specifies the data type of the columns to display in the list:
'C' | |
'N' | |
'A' |
The list contains all of the columns. (This is the default.) |
is the maximum number of items a user can select from the list. The default is 1. To display the list for information purposes only (no selections allowed), specify 0 . To specify an unlimited number of selections, use a value such as 9999 that is larger than the number of available selections. A user cannot make a number of selections that exceeds the number of items in the list.
is the text for a message to display above the selection list. The default message tells users to make up to the number of selections specified in num-sel.
is an obsolete argument but is retained for compatibility with earlier releases. If you want to specify a value for sel-order, exclude, or select, then specify " as a placeholder for this argument.
is an obsolete argument but is retained for compatibility with earlier releases. If you want to specify a value for exclude or select, then you must specify " as a placeholder.
lists one or more columns to exclude from the selection list. Separate multiple columns with at least one blank.
lists one or more columns to select for the selection list. Separate multiple columns with at least one blank.
Details |
VARLIST opens a dialog window in which a user can select columns from a SAS table. The columns specified in the VARLIST function are listed in the Available list. To make a selection, a user selects one or more columns and then presses the arrow control that points to the Selected list. The selected values move to the Selected list and are removed from the Available list. The Variable Details fields display the type, length, and description of a selected column.
For each column in the table, VARLIST uses the following steps to determine which columns to display:
If one or more column names are specified in the select argument, VARLIST includes those columns in the selection list. Columns that are not in the select argument list do not appear in the selection list.
If one or more column names are specified in the exclude argument, VARLIST excludes those columns from the selection list.
If a value is specified for the var-type argument, VARLIST excludes all columns that are not of the specified type.
You can provide default values that will be initially selected when the column selection list is displayed. To do this, assign the column name to the selections variable before calling VARLIST. When the window opens, the column name appears in the Selected list.
If a user closes the dialog window without making a selection, VARLIST returns a blank value unless there was an initial value for the selections column before VARLIST was called.
The values for all selections can be returned in the current result list, if one is available. The current result list is a special SCL list that is automatically filled with the values selected from a selection list. To use a current result list, use the MAKELIST function to create the list, and use the CURLIST function to designate it as the current result list. The current result list must exist before you call the VARLIST function. You can use GETITEMC to retrieve these selections.
Examples |
Display all columns and allow the user to select only one:
select=varlist(dsid,'a',1);
This next statement displays only character columns, allows two selections, uses a custom message, moves the selections to the top of the list when they are selected, and excludes the columns NAME and ADDRESS:
select=varlist(dsid,'c',2,'Choose a column', '','','name address');
Display a dialog window that contains the character columns from an open SAS table, excluding the columns NAME and ADDRESS. Users can make two selections. The selected column names are retrieved from the current result list. LISTLEN returns the number of selections because there is only one element in the list for each selection made.
listid=makelist(); rc=curlist(listid); select=varlist(dsid,'c',2, 'Choose a column','',",'name address'); n=listlen(listid); do i=1 to n; varname=getitemc(listid,i); put varname=; end;
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.