length quotes $ 8; INIT: dsid=open('sasuser.class'); numobs=attrn(dsid,'nobs'); /* make a list for the variable names */ varnames=makelist(); nvars=attrn(dsid,'nvars'); /* insert variable names in Varnames */ do i=1 to nvars; vname=varname(dsid,i); rc=insertc(varnames,vname,-1); end; call putlist(varnames,'list of variable names=',0); listid1=makelist(); mainlist=makelist(); selid=getiteml(lbox,1); call notify('lbox','_set_title_',''); call notify('lbox','_set_maxsel_',numobs); choice=0; return; /*Init*/ SELECT: link choices; choice=popmenu(varnames); if choice then do; vrname=getitemc(varnames,choice); found=nameditem(listid1,vrname); if not found then do; list=makelist(); rc=insertl(listid1,list,-1,vrname); end; else do; list=getiteml(listid1,found); end; call notify('lbox','_set_title_','Choose values for '||vrname); /* fill mainlist with the values of the chose variable */ nlevels=0; rc=lvarlevel(dsid,vrname,nlevels,mainlist); /* repopulate the listbox */ call notify('lbox','_repopulate_'); /* select previous choices */ do i=1 to listlen(list); val=getitemc(list,i); found=searchc(mainlist,val); if found then call notify('lbox','_select_row_',found); end; end ; /* end choice */ return; CHOICES: if choice then do; rc=clearlist(list); do i=1 to listlen(selid); val=getitemc(selid,i); rc=insertc(list,val,i); end; end; call putlist(listid1,'listid1=',0); return; UNSELECT: call notify('lbox','_unselect_all_'); return; PREVIEW: link choices; link gencode; rc=preview('display'); return; GENCODE: rc=preview('clear'); submit ; data temp; set sasuser.class; endsubmit; if listlen(listid1) then do; do j=1 to listlen(listid1); name=nameitem(listid1,j); vtype=vartype(dsid,varnum(dsid,name)); id=getiteml(listid1,j); if listlen(id) then do; do i=1 to listlen(id); if i=1 then do; where='where also '||name||' in ('; end; else do; where=' '; end; if vtype='C' then quotes='"'; else quotes=''; val=getitemc(id,i); submit; &where"es&val"es endsubmit; end; end; if listlen(getiteml(listid1,j)) then do; submit; ); endsubmit; end; end; end; submit ; ;run; endsubmit; return; SUBMIT: link choices; link gencode; submit continue; run; endsubmit; return; TERM: if dsid then dsid=close(dsid); if mainlist then rc=dellist(mainlist); if listid1 then rc=dellist(listid1,'y'); if varnames then rc=dellist(varnames); rc=preview('clear'); if (exist('temp')) then rc=delete('temp'); return;