Search with SAS can be started from the Srcshell run editor or from SAS. Using the Search SAS example, here’s how.
Starting from the Srcshell run editor
- Download and install Srclib as described in the Search Installation Guide.
- In Windows start the Srcshell run editor. In Linux or Mac OS X run emacs with “-l ~/srclib/srcshell.el” as a command-line or icon option.
- Open or create and save an XML file (.xml) with the following structure, replacing the SAS run name and statements and Search run name and statements with your own.
<sas name="search_example"> /* search example - sas version */ /* import the input dataset */ proc import datafile='search_data.txt' out=search_data dbms=tab replace; getnames=yes; run; data search_data; set search_data; attrib V16306 label="SIZE LGST CITY/COUNTY 89" V16631 label="AGE OF 1989 HEAD" V16973 label="D1 CHKPT" V17459 label="L7 GREW UP FARM OR? HD" V17466 label="L13 PARENTS POOR OR? HD" V17467 label="L14-15 EDUC OF FATHER H" V17468 label="L16-17 EDUC OF MOTHER H" V17483 label="L32 RACE OF HEAD 1" V17536 label="HEAD 88 AVG HRLY EARNING" V17538 label="REGION OF 1989 INTERVIEW" V17543 label="HEAD GEOGRAPHIC MOBILITY" V17545 label="EDUCATION 1989 HEAD" V17612 label="1989 FAMILY WEIGHT"; run; /* run search */ <search name="search"> datain search_data; dataout search; title Hourly earnings analysis; depv=v17536 wt=v17612 null=.05 expl=0.4 estimate=r20 group=r30; v=(v16306,v16631,v17459,v17466,v17467,v17468,v17483,v17543,v17545); v=(v16973,v17538) s; run; </search> </sas>
If the search.set file exists, perhaps from a previous run, you can reuse it by replacing <search name=”search”>…</search> with the following.
<search name="search" />
- In Srcshell, click “run”. In emacs, press F8.
Once you’ve created a SAS setup file, search_example.sas in the example, you can reuse it by issuing the following command.
sas search_example.sas
Starting from SAS
- Download and install Srclib as described in the Search Installation Guide.
- Start SAS.
- Change to the working directory you want to use.
- In the Program Editor (NOT the Windows Enhanced Editor), open or create and save a SAS program (.sas) file with the following structure, replacing the SRCLIB environmental variable, the SAS statements and the Search run name and statements with your own. Note that the SRCLIB environmental variable is the sas subdirectory of the srclib directory. This is a change from previous installations.
options set = SRCLIB '~/srclib/sas' sasautos = ('!SRCLIB' sasautos) mautosource; /* search example - sas version */ /* import the input dataset */ proc import datafile='search_data.txt' out=search_data dbms=tab replace; getnames=yes; run; data search_data; set search_data; attrib V16306 label="SIZE LGST CITY/COUNTY 89" V16631 label="AGE OF 1989 HEAD" V16973 label="D1 CHKPT" V17459 label="L7 GREW UP FARM OR? HD" V17466 label="L13 PARENTS POOR OR? HD" V17467 label="L14-15 EDUC OF FATHER H" V17468 label="L16-17 EDUC OF MOTHER H" V17483 label="L32 RACE OF HEAD 1" V17536 label="HEAD 88 AVG HRLY EARNING" V17538 label="REGION OF 1989 INTERVIEW" V17543 label="HEAD GEOGRAPHIC MOBILITY" V17545 label="EDUCATION 1989 HEAD" V17612 label="1989 FAMILY WEIGHT"; run; /* run search */ %search(name=search, dir=., setup=new); datain search_data; dataout search; title Hourly earnings analysis; depv=v17536 wt=v17612 null=.05 expl=0.4 estimate=r20 group=r30; v=(v16306,v16631,v17459,v17466,v17467,v17468,v17483,v17543,v17545); v=(v16973,v17538) s; run;
- Click “run”.