Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: programming question

From   John Baughman <>
Subject   st: programming question
Date   Wed, 23 Jul 2003 15:28:26 -0400

I have a fair amount of experience using Stata interactively, but little programming experience, and I now have run into a problem that can only be solved with programming (I think). Any help with how I ought to think about it would be greatly appreciated. Thus, my first post to the list. By the way, I'm using Intercooled Stata 8.1.

The dataset has a string var whose values correspond to the names of dummy variables in the dataset. What I want to do is generate a new dummy var which equals 1 for a given observation if the dummy for the var whose name corresponds to that observation's string value also equals 1; the new dummy will be 0 otherwise. I think an illustration of what the data might look like will help more than that convoluted description:

obs strvar aaa bbb ccc newvar
1 aaa 1 1 1 1
2 ccc 1 0 1 1
3 bbb 1 0 1 0
4 ccc 0 0 1 1
5 aaa 0 0 0 0

etc etc in various permutations.

The actual dataset has fifty string values and fifty corresponding dichotomous vars and around 5500 observations. Any ideas about how I ought to think about this and/or what commands might be useful in getting this coded? I sense there is something simple I'm missing . . .



John Baughman
Assistant Professor of Political Science
Bates College
Lewiston, ME 04240
voice: (207) 786-6465 fax: (207) 786-8333
* For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index