- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 09-21-2023 09:31 AM
(1471 views)
Hi Everyone,
I have a requirement to read a text file which contains SQL query into a single column in SAS Dataset. Could you please help.
For Example, I have a emp.txt file and which contains below query.
Select * from emp where sal > 5000 and deptno=30;
Above one is simple query, but I have big queries too. Thank you.
I have a requirement to read a text file which contains SQL query into a single column in SAS Dataset. Could you please help.
For Example, I have a emp.txt file and which contains below query.
Select * from emp where sal > 5000 and deptno=30;
Above one is simple query, but I have big queries too. Thank you.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SAS data sets do not usually contain SQL code, they usually contain data. Are you sure that is the requirement? SAS data sets would be a poor choice for a place to store code. Could it be that the requirement is to read SQL code into a SAS program?
--
Paige Miller
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This is part of one of the automation. Users will give me one query, and I will need to break that query into all possible queries using where clause column /conditions to verify which query throwing 0 records.
Ex:
Query1: select * from emp where sal>5000;
Query2: select * from emp where sal>5000 and deptno=30;
Once I make the diff queries based on the input query, will submit queries to find whether all queries populating data or not.
As part of this, first I want to read the query into a single column in SAS Dataset.
Ex:
Query1: select * from emp where sal>5000;
Query2: select * from emp where sal>5000 and deptno=30;
Once I make the diff queries based on the input query, will submit queries to find whether all queries populating data or not.
As part of this, first I want to read the query into a single column in SAS Dataset.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Banu wrote:
This is part of one of the automation. Users will give me one query, and I will need to break that query into all possible queries using where clause column /conditions to verify which query throwing 0 records.
Ex:
Query1: select * from emp where sal>5000;
Query2: select * from emp where sal>5000 and deptno=30;
Once I make the diff queries based on the input query, will submit queries to find whether all queries populating data or not.
As part of this, first I want to read the query into a single column in SAS Dataset.
Reading text from a file is trivial.
Making sense of it as SQL syntax is difficult.
One restriction is that character variables can only store 32K bytes. So your will have a limit on how large a block of code you can put into a single variable.
data want;
infile 'codefile' truncover ;
input codeline $32767.;
run;