Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • searchfor : New Program on SSC

    Hi everyone
    Everyone now and then, I find myself searching for specific text inside the data set. While Stata has many built-in functions to search and match text, I find it cumbersome to type the required syntax. For my convenience, I have written a program, searchfor which I want to share with others as well. I hope it will be of some help to others. The program can be installed from SSC
    Code:
    ssc install searchfor
    Following are the details and example of how to use it.

    -------------------------------------------------------------------------------------------------------------------------------------

    Title

    searchfor - Searches for texts in selected or all string variables


    Syntax

    searchfor TEXT , in(varlist) edit(varlist) list(varlist)



    Description

    This program finds text in string variables and either lists the selected variables
    on screen or edits the variables in Data Editor. The search text is capitalization free.



    Syntax Details

    The program has 3 options: They are
    1. in : to select string variables in which the text will searched for. If left empty, the desired text will be searched in all
    string variables.
    2. edit: This option will edit selected variables in the Data Editor in instances where the search result is true
    3. list: This option will list selected variables in instances where the search result is true;


    Example 1: Find Text in all String Variables

    . sysuse census.dta

    . searchfor Alabama

    . searchfor Alab

    . searchfor ALAB



    Example 2: Show Selected Variables Where searchfor Finds Matching string

    . searchfor Alabama, list(state state2 region pop)


    Example 3: Find Text in Selected String Variables

    . searchfor Alabama, in(state)

    This will search for Alabama in the variable 'state' only

    . searchfor Alabama, in(state) list(state state2 region pop)


    Example 4: Find Text in Selected String Variables and Edits Selected variables

    . searchfor Alabama, in(state) edit(state state2 region pop)


    This will search for Alabama in the variable 'state' only and edit state, state2, region, and pop variables in the editor
    window where the search finds a match


    Author


    :::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::: *
    * *
    * Dr. Attaullah Shah *
    * Institute of Management Sciences, Peshawar, Pakistan *
    * Email: [email protected] *
    *::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::*
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

  • #2
    With edit, do you mean it opens the editor window and shows those observations?

    Comment


    • #3
      Jesse Wursten yes, it opens the data editor and shows those observations.
      Regards
      --------------------------------------------------
      Attaullah Shah, PhD.
      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
      FinTechProfessor.com
      https://asdocx.com
      Check out my asdoc program, which sends outputs to MS Word.
      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

      Comment

      Working...
      X