DATA Step, Macro, Functions and more

SQLite using Pipes

Occasional Contributor NDS
Occasional Contributor
Posts: 10

SQLite using Pipes


I am trying to access a SQLite database using pipes as follows:

filename QUERY pipe 'sqlite3 home/data/MyDB.db3 "select field1 from table1"';
  options linesize = max;

    data mySet;
      infile QUERY delimiter = '|' missover dsd lrecl = 32767;

I have simplified the query, but the original runs fine from SQLite studio.

However when I run this, I get a single row in my data table with SQL ERROR in it.

If anyone can shed any light on this I'd appreciate it.

Many thanks


SAS Employee
Posts: 26

Re: SQLite using Pipes

Run your command in a bare DOS window instead of the IDE.

If it runs in the DOS window, we'll need to investiage PIPE further.

Occasional Contributor NDS
Occasional Contributor
Posts: 10

Re: SQLite using Pipes

Posted in reply to jwsquillace


Sorry - took some time to get back to this. I have tried what you suggested and I have a couple of issues:

1. A simple SQL command runs fine from the prompt (i.e. Select * from MYTABLE) - and the same simple query runs fine from in SAS using pipes.

2. When I try to select from a view (from the prompt or SAS) I get an error that the column name can't be found (i.e. Select * from [myView]) this squery works fine in the IDE

It must be interpreting the query that defines the view correctly as it is looking for the right column.

Is there some issue selecting from views using sqlite3?

One possible issue is that the original .db3 file was created in a windows environment and I have copied it over to a unix environment. I tried dos2unix but that seemed to corrupt the file....

Any ideas?

Super User
Posts: 5,884

Re: SQLite using Pipes

Since it seems it's not SAS that is the issue, you might find answers in a different forum. The average SAS user have no experience with SQLite...;-)

Data never sleeps
Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation