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, **statalist.org** is already up and running.

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

From |
Andrin Foster <akf7@case.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Re: how to implement a dictionary (aka map, look-up table) |

Date |
Sat, 15 Dec 2012 19:45:15 -0500 |

I'm trying to set a value based on observation variables matching relevant dictionary entries. I've tried to implement a dictionary amongst the variables in Stata, however, I can't compare my results to the dictionary because the dictionary entries and results are counted as different observations. my code was: gen Value = MetaValue if X==MetaX & Y==MetaY & Z==MetaZ where the data used was formatted as such: ================================================== X Y Z MetaX MetaY MetaZ MetaValue -------------------------------------------------------------------------------------- 1 5 3 . . . . 3 2 7 . . . . 9 1 4 . . . . . . . 1 1 1 2 . . . 1 1 2 3 . . . 1 2 1 5 ================================================== Running the above code will not output an error code but will instead produce all missing values since the comparisons always resolve to false. In psudocode, Stata is currently running... for i in range observations: Value[i] = MetaValue[i] if X[i]==MetaX[i] & Y[i]==MetaY[i] & Z[i]==MetaZ[i] ...when what I need is... for i in range observations: for k in range dictionary: Value[i] = MetaValue[k] if X[i]==MetaX[k] & Y[i]==MetaY[k] & Z[i]==MetaZ[k] What is the proper function or data format to achieve my goal? I'm using Stata 12 on Mac OS 10.7.5 * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**st: how to implement a dictionary (aka map, look-up table)** - Next by Date:
**Re: st: how to implement a dictionary (aka map, look-up table)** - Previous by thread:
**st: how to implement a dictionary (aka map, look-up table)** - Next by thread:
**st: System GMM** - Index(es):