Hi gyes.
Can you please, say me what is wrong in this code:
libname test "C:\Temp";
%macro checkfk(pkTab, pk, fkTab, fk, out=results, print=no);
%let tmp='';
proc sql;
select name into :tmp separated by ' ' from TRIM("test."||&fkTab)
where TRIM("test."||&fk) in (TRIM("test."||&pk));
quit;
%mend checkfk;
%checkfk(pkTab=Sex, pk=Names.sex_id, fkTab=Names, fk=Sex.sex_id, out=results, print=yes);
Here is the log:
293 libname test "C:\Temp";
NOTE: Libref TEST was successfully assigned as follows:
Engine: V9
Physical Name: C:\Temp
294
295 %macro checkfk(pkTab, pk, fkTab, fk, out=results, print=no);
296 %let tmp='';
297 proc sql;
298 select name into :tmp separated by ' ' from TRIM("test."||&fkTab)
299 where TRIM("test."||&fk) in (TRIM("test."||&pk));
300 quit;
301 %mend checkfk;
302
303
304 %checkfk(pkTab=Sex, pk=Names.sex_id, fkTab=Names, fk=Sex.sex_id, out=results, print=yes);
NOTE: Line generated by the invoked macro "CHECKFK".
1 select name into :tmp separated by ' ' from TRIM("test."||&fkTab)
1 ! where TRIM("test."||&fk) in (TRIM("test."||&pk)); quit;
----
79
76
ERROR 79-322: Expecting a SELECT.
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
There are 2 tables:
Table Names with 3 columns name_id, name, sex_id
Table Sex with 2 columns sex_id, sex