English 中文(简体)
What s the easiest way to use SQLite with SAS?
原标题:
  • 时间:2009-12-30 22:22:40
  •  标签:
  • sqlite
  • sas

I want to investigate how to access SQLite DB from SAS. What s the easiest way of doing this? Is there a SAS product that we can license to do that? I don t want to use ODBC drivers as that seems to have been written a long time ago and is not officially part of SQLite.

问题回答

SAS supports reading data from pipes (in a unix environment). Essentially, you can set up a filename statement to execute an sqlite command in the host environment, then process the command output as if reading it from a text file.

SAS Support page: http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#pipe.htm

Example:

*----------------------------------------------
* (1) Write a command in place of the file path
*     --> important: the  pipe  option makes this work
*----------------------------------------------;

filename QUERY pipe  sqlite3 database_file "select * from table_name" ;



*----------------------------------------------
* (2) Use a datastep to read the output from sqlite
*----------------------------------------------;

options linesize=max; *to prevent truncation of results;

data table_name;

   infile QUERY delimiter= |  missover dsd lrecl=32767;

   length 
      numeric_id 8
      numeric_field 8
      character_field_1 $40
      character_field_2 $20
      wide_character_field $500
   ;

   input
      numeric_id 
      numeric_field $
      character_field_1 $
      character_field_2 $
      wide_character_field $
   ;

run;



*----------------------------------------------
* (3) View the results, process data etc.
*----------------------------------------------;

proc contents;
proc means;
proc print;
run;




相关问题
sqlite3 is chopping/cutting/truncating my text columns

I have values being cut off and would like to display the full values. Sqlite3 -column -header locations.dbs " select n.namelist, f.state, t.state from names n left join locations l on l.id = n.id ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...

Metadata for columns in SQLite v2.8 (PHP5)

How can I get metadata / constraints (primary key and "null allowed" in particular) for each column in a SQLite v2.8 table using PHP5 (like mysql_fetch_field for MySql)? sqlite_fetch_column_types (OO:...

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签