将 SQLite 与 SAS 结合使用的最简单方法是什么?

发布于 2024-08-16 14:20:43 字数 118 浏览 5 评论 0原文

我想研究如何从 SAS 访问 SQLite DB。做到这一点最简单的方法是什么?我们是否可以授权 SAS 产品来执行此操作?我不想使用 ODBC 驱动程序,因为它似乎是很久以前编写的,并且不是 SQLite 的正式一部分。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苹果你个爱泡泡 2024-08-23 14:20:43

SAS支持从管道读取数据(在unix环境中)。本质上,您可以设置一个文件名语句来在主机环境中执行 sqlite 命令,然后处理命令输出,就像从文本文件中读取它一样。

SAS 支持页面:http:// /support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#pipe.htm

示例:

*----------------------------------------------
* (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;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文