LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2003)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 4 Dec 2003 17:45:37 +1100
Reply-To:   Frank Milthorpe <Frank.Milthorpe@dipnr.nsw.gov.au>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Frank Milthorpe <Frank.Milthorpe@dipnr.nsw.gov.au>
Subject:   Solution to use the full power of SQL to retrieve data using ODBC: GET DATA & GET CAPTURE
Content-Type:   text/plain; charset=US-ASCII

There are two different SPSS commands that you can use to get data from your ODBC database back to SPSS. They are GET DATA and GET CAPTURE.

GET DATA is the original version of the command. This command may be phased out in a future version of SPSS.

GET DATA is the newer version and is used by the wizard.

One disadvantage of the GET DATA version is that each line of the SQL SELECT statement must be enclosed in quotes.

I have also verified (at least connecting to Oracle) that both commands allow you to use the full power of SQL if you wish to write it yourself. This allows you to have much "cleaner" than that generated by the wizard.

See the following example. Note that I define some of the connection stuff !o_oracle and !o_user in an INCLUDE FILE that is read in from the users personal directory.

GET CAPTURE ODBC / CONNECT= !o_oracle+!o_user / UNENCRYPTED / SELECT trip.*, tour.*, dist.road_dist as tourdist FROM hts2001.trip trip, hts2001.stm_home_tour_pd1 tour, equiv.distance96_gis dist WHERE (trip.hh_ssd96 < 1000) and (trip.day_no <=5) and (trip.sample_no = tour.sample_no) and ...

The same SQL syntax can be used with GET DATA.

GET DATA / TYPE=ODBC / CONNECT= !o_oracle+!o_user / UNENCRYPTED / SQL = ' SELECT ' ' trip.*, ' ' tour.*, ' ' dist.road_dist as tourdist ' ' FROM ' ' hts2001.trip trip, ' ' hts2001.stm_home_tour_pd1 tour, ' ' equiv.distance96_gis dist ' ' WHERE ' ' (trip.hh_ssd96 < 1000) and ' ' (trip.day_no <=5) and ' ' (trip.sample_no = tour.sample_no) and ' ...

Personally I find having to insert the quotes on each line to be a real nuisance.

Thanks to a SPSS staffer who sent me an email message pointing out that I could still use GET CATURE with SPSS version 11.5.

I think that you should be able to use this SQL power to extract data from Access and other databases.

Perhaps an example showing this in the syntax manual would be useful (I am making the assumption that not everyone is aware that this can be done).

Regards

Frank Milthorpe

-------------------------------------------- Frank Milthorpe Transport Modelling Manager Transport and Population Data Centre (TPDC) Department of Infrastructure, Planning and Natural Resources GPO Box 3927, Sydney NSW 2001 Level 5, 20 Lee Street, Sydney

Direct: +61 2 9762 8488 Tel: +61 2 9762 8511 Fax: +61 2 9762 8514 Email: frank.milthorpe@dipnr.nsw.gov.au


Back to: Top of message | Previous page | Main SPSSX-L page