Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: R: filter string variable

From   "Carlo Lazzaro" <>
To   <>
Subject   st: R: filter string variable
Date   Mon, 25 Mar 2013 12:54:13 +0100

Dear Victor,
in its triviality, the following example might hopefully help you out:

set obs 10
g Lobbists="agri" in 1/3
replace Lobbists="farm" in 4/6
replace Lobbists="corn" in 7
replace Lobbists="white_collar" in 8/10
encode Lobbists, g( Lobbists_2)
label list Lobbists_2
replace Lobbists_2=1 if Lobbists_2!=4
list Lobbists_2 if Lobbists_2==1

Kindest regards,

-----Messaggio originale-----
Da: [] Per conto di victor
Inviato: lunedì 25 marzo 2013 12:03
Oggetto: st: filter string variable


I have a dataset which contains the amount of contributions from various lobbies to a member of congress. However, for my research I am only interested in the contributions from the agricultural lobby. Therefore, I would like to filter in a way that keeps only the observations which contain words like “agri” or “farm” etc. in it. Since I have to do this for various members of congress on several occasions I would like to make some sort of code for it. So far I am unable to work something out.

Can anyone help me out on this?

Thanks in advance,

View this message in context:
Sent from the Statalist mailing list archive at

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index