Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: macro problem

From   Jeph Herrin <>
Subject   st: macro problem
Date   Mon, 11 Jun 2012 11:50:36 -0400

This should be trivial, but for some reason I cannot get it.

I have a string variable, and I have a list of string values I need to match against it. There are occasional trailing or leading characters in the variable, so I am using -strpos- to find matches. Thus

  local matchlist "string 1" "string 2"  "string 3" .... "string 55"

  gen byte match=0
  foreach S in `matchlist' {
        replace match = 1 if strpos(strvar,`S')

Now, I know I have got the quotes and macro evaluations wrong, but that is the problem: I've tried this many different ways, and yet cannot seem to find a combination that works. Any thoughts?

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index