I'm just starting to learn SQL/PROC SQL so hopefully this is an easy question to answer. I want to take the values from one
SQL statement and use them in another. I am using an "INTO" statement because it's handy at creating a delimeter. However
when I need to use the "IN" statement in my where clause I need to concatenate the (' to the front and the ') to the end. I thought
it would be straightforward but I seem to get some sort of error no matter what I put in there.
My Example below
-----------------------------------------------------------------------------------------------
proc sql;
select ID INTO :ID_VAR SEPARATED BY ''',''' from DB_RECORD WHERE FAMILY = 'ProductX';
QUIT;
%put &ID_VAR;
-----------------------------------------------------------------------------------------------
this yields &ID_VAR as
ID1','ID2','ID3','ID4
I then want to be able to query another database table with the contents of the &ID_VAR concatenated
with (' on the front and ') on the back so that it works in my IN clause
-----------------------------------------------------------------------------------------------
proc sql;
select runtime, equipment from DB_PROCESS WHERE ID IN xxx;
quit;
-----------------------------------------------------------------------------------------------
Obviously i'm looking to create xxx. Maybe I'm going about this wrong but it seemed easy at the time.
Please help me as I'm a noob.