/* SELECT.G: procedure to select a subset of variables for estimation from a list of variable names in ASCII file x containing three columns: column 1: sequence number of the variable, 1, 2, 3, ..., rows(x) column 2: binary include/exclude indicator (exclude iff 0) column 3: 8 character variable mnemonic column 4: number of observations for variable (ignored) Procedure outputs the sequence numbers of the variables selected and corresponding mnemonics. These are used in maximum likelihood program to select independent variables and display variable mnemonics next to parameter estimates Outputs: iloc : position numbers of independent variables ivar : character mnemonics of independent variables dloc : position number of dependent variable (marked with 'd') dvar : character mnemonic of dependent variable cloc : position number of constant term (marked with 'c') By John Rust, University of Maryland. October, 2006. */ proc (5)=select(x); local v,cloc,dloc,dvar,iloc,ivar,i; load v[]=^x; v=reshape(v,rows(v)/4,4); cloc=maxindc(((upper(v[.,2]) .$== "C").or (upper(v[.,3]) .$== "CONST"))); if ((cloc == 1) and (upper(v[cloc,2]) $/= "C") and (upper(v[cloc,3]) $/= "CONST")); cloc=0; endif; dloc=maxindc(((v[.,2] .$== "d").or (v[.,2] .$== "D"))); dvar=v[dloc,3]; iloc=packr(v[.,1] .*miss(((v[.,2] .$== 1).or (v[.,2] .$== "c").or (v[.,2] .$== "C")),0)); if scalmiss(iloc); "ERROR: no variables selected from "$+x; ivar=v[1,3]; else; ivar=v[iloc,3]; endif; i=1; do until i > rows(ivar); if (vals(strsect(ivar[i],strlen(ivar[i]),1)) == 10); ivar[i]=strsect(ivar[i],1,strlen(ivar[i])-1); endif; i=i+1; endo; retp(iloc,ivar,dvar,dloc,cloc); endp;