Software: Search: Software for Exploring Data Structure: Search Documentation

Search with Stata

Search with Stata can be started from the Srcshell run editor or from Stata. Using the Search Stata example, here’s how.

Starting from the Srcshell run editor

  1. Download and install Srclib as described in the Search Installation Guide.
  2. 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.
  3. Open or create and save an XML file (.xml) with the following structure, replacing the Stata run name and statements and Search run name and statements with your own.
    <stata name="search_example">
    
    /* search example - stata version */
    
    /* import the input dataset */
    
    insheet using search_data.txt, clear names case tab
    label var V16306 "SIZE LGST CITY/COUNTY 89"
    label var V16631 "AGE OF 1989 HEAD"
    label var V16973 "D1 CHKPT"
    label var V17459 "L7 GREW UP FARM OR?   HD"
    label var V17466 "L13 PARENTS POOR OR?  HD"
    label var V17467 "L14-15 EDUC OF FATHER  H"
    label var V17468 "L16-17 EDUC OF MOTHER  H"
    label var V17483 "L32 RACE OF HEAD 1"
    label var V17536 "HEAD 88 AVG HRLY EARNING"
    label var V17538 "REGION OF 1989 INTERVIEW"
    label var V17543 "HEAD GEOGRAPHIC MOBILITY"
    label var V17545 "EDUCATION 1989 HEAD"
    label var V17612 "1989 FAMILY WEIGHT"
    save search_data, replace
    
    /* 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>
    
    </stata>
    

    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" />
    
  4. In Srcshell, click “run”. In emacs, press F8.

    Once you’ve created a Stata setup file, search_example.do in the example, you can reuse it by issuing the following command.

    stata search_example.do
    

Starting from Stata

  1. Download and install Srclib as described in the Search Installation Guide.
  2. Start Stata.
  3. Change to the working directory you want to use.
  4. In the Stata Do-File Editor, create and save an Search setup file (.set) with the following structure, replacing the Search statements with your own. The name of the opened or saved file should be the one you use in the global name statement below.
    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;
    
  5. In the Do-File Editor, open or create a Stata setup with the following structure, replacing the srclib location, the Stata statements and the Search run name with your own. Note that the srclib import path is the stata subdirectory of the srclib directory. This is a change from previous installations.
    global srclib "~/srclib/stata"
    
    /* search example - stata version */
    
    /* import the input dataset */
    
    insheet using search_data.txt, clear names case tab
    label var V16306 "SIZE LGST CITY/COUNTY 89"
    label var V16631 "AGE OF 1989 HEAD"
    label var V16973 "D1 CHKPT"
    label var V17459 "L7 GREW UP FARM OR?   HD"
    label var V17466 "L13 PARENTS POOR OR?  HD"
    label var V17467 "L14-15 EDUC OF FATHER  H"
    label var V17468 "L16-17 EDUC OF MOTHER  H"
    label var V17483 "L32 RACE OF HEAD 1"
    label var V17536 "HEAD 88 AVG HRLY EARNING"
    label var V17538 "REGION OF 1989 INTERVIEW"
    label var V17543 "HEAD GEOGRAPHIC MOBILITY"
    label var V17545 "EDUCATION 1989 HEAD"
    label var V17612 "1989 FAMILY WEIGHT"
    save search_data, replace
    
    /* run search */
    
    global name "search"
    do $srclib/search
    
  6. Click “run”.

Last updated 19 July 2016