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


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

st: odbc load from SQL if ID is in my Stata master dataset?


From   Jen Zhen <jenzhen99@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: odbc load from SQL if ID is in my Stata master dataset?
Date   Tue, 18 Sep 2012 13:46:59 +0200

Dear list members,

I have a list of person ID numbers for whom I would like to merge in
information from a large SQL dataset (containing the IDs in the first
list, plus many more).

I assume that I cannot directly merge in from the SQL dataset, but
must first load the SQL dataset into Stata, save as dta, and then I
can merge that into my main dataset.

However, I'm wondering how, when loading from SQL with --odbc load-- I
can best specify that I'm only interested in observations with a fixed
list of ID numbers?

What would work is to write "WHERE id=51 OR id=332 OR ...", but since
I have several hundred valid IDs this seems inefficient.

Would anyone happen to know a better way?

Thanks so much and best regards,
JZ
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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