If your variable is string, as I guess,
. gen byte found = (strpos(codeks, "A") > 0) | (strpos(codeks, "X") > 0)
Nick
[email protected]
Thaddee Badibanga
I'd like to create an index from a
variable which is a pseudo numeric or a string(numeric
as well character). This index will allow me to
eliminate some observations in the dataset. To give
you an idea, the variable I termed codeks is as
follows:
codeks:101 102 01A 01X 0AX ...103 ... 111 112 ...11111
I'd like to create an index that assigns 1 if codeks
includes A or X or AX and 0 otherwise. I have done
this in other programs. In one program for instance,
this can be done as:
found=indexc(codeks,"A","X")
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/