Sample 25991: Building a WHERE clause with multiple values selected from a List Box Control
The following SAS Component Language (SCL) program populates the list of values for the IN operator in a WHERE statement that is executed within a DATA step using multiple values selected from a list box control within a SAS/AF FRAME entry. In this example, the frame contains a list box control named LISTBOX1 and a push button control named SUBMIT. In the Properties window, you will need to set the selectionMode attribute for the list box control to Multiple Selections to allow multiple items to be selected.
When the push button is selected, loop through the selected items in the list box and use these to populate the list of values for the IN operator in the WHERE statement as you build the SAS code to be submitted. You will use SUBMIT statements as you build the SAS code and then a SUBMIT CONTINUE statement when you are ready to send the complete code to be executed by SAS.
/* FRAME SCL code */
rc=rc;
SUBMIT:
if listbox1.selectedItems > 0 then
do;
submit;
data work.class;
set sashelp.class;
where name in(
endsubmit;
do i=1 to listlen(listbox1.selectedItems);
val=getitemc(listbox1.selecteditems,i);
if i=listlen(listbox1.selectedItems) then
do;
submit;
"&val"
endsubmit;
end;
else
do;
submit;
"&val",
endsubmit;
end;
end;
submit;
);
run;
endsubmit;
* rc=preview('edit');
submit continue;
endsubmit;
end;
return;
|
If you would like to see the SAS code in the Preview window before it is submitted to SAS, you can uncomment the following statement:
Download the transport file and use the CIMPORT procedure to import the transport file. The following is example syntax where the transport file resides in the directory c:\Mysamples
proc cimport lib=work
infile='c:\Mysamples\sample1562.xpt';
run;
|
After importing the catalog, you can then run the application by issuing the following command within an interactive SAS session:
af c=work.listbox.sample.frame;
|
Download the ZIP file
This sample demonstrates how to populate a list of values for the IN operator in a WHERE clause with multiple values selected from a List Box Control within a SAS/AF FRAME entry.
| Date Modified: | 2005-12-14 03:02:40 |
| Date Created: | 2005-11-30 11:26:59 |
Operating System and Release Information
| SAS System | SAS/AF | Solaris | 8.2 TS2M0 | n/a |
| Tru64 UNIX | 8.2 TS2M0 | n/a |
| Linux | 8.2 TS2M0 | n/a |
| HP-UX IPF | 8.2 TS2M0 | n/a |
| HP-UX | 8.2 TS2M0 | n/a |
| AIX | 8.2 TS2M0 | n/a |
| 64-bit Enabled Solaris | 8.2 TS2M0 | n/a |
| ABI+ for Intel Architecture | 8.2 TS2M0 | n/a |
| 64-bit Enabled HP-UX | 8.2 TS2M0 | n/a |
| 64-bit Enabled AIX | 8.2 TS2M0 | n/a |
| OS/2 | 8.2 TS2M0 | n/a |