Chapter Contents |
Previous |
Next |
DATALISTC and DATALISTN |
Category: | SAS Table |
Syntax | |
Details | |
Examples | |
Example 1: Using DATALISTC to Return a Single Selection | |
Example 2: Using DATALISTN to Return Multiple Selections | |
See Also |
Syntax |
selection=DATALISTC(table-id,
col-list<,message<,autoclose<,num-sel>>>); |
selection=DATALISTN(table-id,
col-list<,message<,autoclose<,num-sel>>>); |
For DATALISTC, selection is blank if the selection list window is closed and no selections are made. By default, selection is 200 bytes long. To accommodate a value longer than 200 bytes, explicitly declare selection with a longer length.
Type: Character, Numeric.
Type: Numeric
Type: Character
Type: Character
'Y' |
closes the window automatically. (This is the default.) |
'N' |
leaves the window open until the user explicitly closes it. |
This option is ignored when num-sel
is not 1. However, use ''
as a placeholder
if you are also specifying a value for num-sel.
Type: Character
0
. To
specify unlimited selections, use a value that is larger than the number of
available selections, such as 9999.
Type: Numeric
Details |
If a user ends the selection list window without making a selection, DATALISTC and DATALISTN return a blank value. If the user exits by using [OK]without making a selection, then the selection variable is set to blank. However, if the user exits using [CANCEL] without making a selection, the selection variable retains any previous value it may have had.
Although a user can position the cursor or mouse pointer anywhere in a row to make a selection from the list, only the value of the first column is returned. (The other column values are displayed for information only.)
When multiple selections are allowed, selection contains only the value of the first column in the last selected row. However, values for displayed columns for all rows that are selected 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 create a current result list, use the MAKELIST function to create it, and use the CURLIST function to designate it as the current result list. The current result list must exist before you call the DATALISTC or DATALISTN function.
By default, a message is displayed asking the user to make one selection, and the selection list window closes automatically when the user makes a selection.
When DATALISTC or DATALISTN is invoked, the current result list is cleared. After DATALISTC or DATALISTN is invoked, the result list contains the following named items:
Type: Character
Type: Numeric
Type: Numeric or Character
Examples |
Create a selection list whose rows contain the values of the columns NAME, STREET, CITY, STATE, and ZIP from the SAS table identified by the SCL variable CLASSID, which was returned by the OPEN function. NAME contains the value for the selected row. The other columns are displayed for information purposes only.
name=datalistc(classid,'name street city state zip');
Create a selection list whose rows contain the values of the columns ITEMNUM, ITEMAMT, CUSTNAM, and CUSTADR from the SAS table identified by the SCL variable SALESID. Allow users to make up to three selections from this selection list. Then retrieve the values for each column for each of the selected rows from the current result list.
salesid=open('sales'); listid=makelist(); rc=curlist(listid); itemnum=datalistn(salesid, 'itemnum itemamt custnam custadr','','',3); n=getnitemn(listid,'COUNT'); do i=1 to n; itemnum=getnitemn(listid,'ITEMNUM',i); itemamt=getnitemn(listid,'ITEMAMT',i); custnam=getnitemc(listid,'CUSTNAM',i); custadr=getnitemc(listid,'CUSTADR',i); put itemnum= itemamt= custnam= custadr=; end; rc=close(salesid);
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.