Hi,
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;
input
field1
;
run;
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
Nick
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.
Hi,
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?
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...;-)
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.