In a data step I would like to conditionally concatenate (stack) two SAS tables. One of the tables may not always be created and would not need to be stacked. When I have a blank library or table name, I am getting errors. Here is the sample code. LIBNAME LIB1 "Filepath";
LIBNAME LIB2 "";
%LET LIB1_TABLE = table_name;
%LET LIB2_TABLE = ;
%LET USE_LIB2 = N;
DATA STACK_TEST;
IF "&USE_LIB1" = "Y" THEN SET LIB1.&LIB1_TABLE. LIB2.&LIB2_TABLE.;
ELSE SET LIB1.&LIB1_TABLE.;
RUN; With this setup, I would expect the code to revert to the else portion of the "if-then-else" but I get errors in my log. %LET LIB1_TABLE = table_name; %LET LIB2_TABLE = ; %LET USE_LIB2 = N; DATA STACK_TEST; IF "&USE_LIB2" = "Y" THEN SET LIB1.&LIB1_TABLE. LIB2.&LIB2_TABLE.; NOTE: Line generated by the macro variable "LIB2_TABLE". LIB2. _____ 22 201 ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;, CUROBS, END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_. ERROR 201-322: The option is not recognized and will be ignored. ELSE SET LIB1.&LIB1_TABLE.; RUN; Does someone have a solution on how to go about conditionally concatenating the two tables in a data step when one of the libraries is not populated because the table does not exist? I am using SAS Enterprise Guide 6.1 (64-bit). I need to perform other tasks within this data step after getting the data from the table(s) which is why I am not using the Append procedure.
... View more