Incorporating SQL in Stata code

Here is a snippet of code showing how one can include SQL in Stata code (I assume that the ODBC connection has been set up).

#delimit ;

local sql "
 SELECT * 
 FROM director_bio.directorship_results
 WHERE non_match AND start_date < date_filed
 ORDER BY random()
 LIMIT 50";

odbc load, exec("`sql'") dsn("iangow") clear;
Advertisements
This entry was posted in PostgreSQL, Stata, Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s