BookmarkSubscribeRSS Feed
archana
Fluorite | Level 6

Hi,

I am trying the below but it is not working.  I am not getting any data. please suggest.

 

data child_id;

infile "$inbound_path/program_child_id.txt" dlm=",";

input id :$11. @@;

run;

proc sql;

select * into :child separated by ','

from child_id;

quit;

create table x as select * from connection to oracle

(select a.*, b.*   from table1 a,
     table2           b

where a.program_id in (&program)

and trim(a.program_child_id) in ('&child')
and a.program_id  = b.program_id
and a.program_child_id  = b.program_child_id

);

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Macro variables need to be enclosed within double quotes.  So your statement;

select * into :child separated by '","'

Note the single then double quotes and doubel then single.  Then in your program:

and trim(a.program_child_id) in ("&child")

Thus it resolves to: in ("abc","def","efg").

Same for program:

where a.program_id in ("&program")


So your code needs to resolve to SQL compliant results.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Also note, this is a duplicate of this thread:

archana
Fluorite | Level 6


This didnt work.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, you will have to be more specific, what didn't work, what errors/warnings etc.

archana
Fluorite | Level 6

Actually it failed.

 

ERROR: ORACLE prepare error: ORA-00904: "&child": invalid identifier.

archana
Fluorite | Level 6

Thank you. It is working after adding this-

 

(%unquote(%str(%'&child%')))

in where statement.

Ksharp
Super User

where findw("&program",strip(a.program),',')


SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 2435 views
  • 0 likes
  • 3 in conversation