In Data Prep, I have the following code which is working great:
proc sql noprint;
create view TEMP_LASR_VIEW_1234 as
SELECT
X.EmployeeID,
X.EmployeeName
FROM
LASRLIB.MyTable X
quit;
/* Drop existing table */
%vdb_dt(LASRLIB.EMPLOYEES);
data LASRLIB.EMPLOYEES ( );
set TEMP_LASR_VIEW_1234 ( );
run;
Now I want to alter this code to insert a hard-coded row in the same data prep script. I tried doing a UNION statement:
SELECT
X.EmployeeID,
X.EmployeeName
FROM
LASRLIB.MyTable X
UNION
SELECT
0,
'EMPTY ROW'
but i keep getting the "Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT, FROMSELECT X.EmployeeID, X.EmployeeName FROM LASRLIB.MyTable X" error.
What is the correct syntax for using hard coded values in this scenario?
Thanks @LinusH
I ended up referencing the table and then just capping the select statement to a single row to avoid multiple entries going into the table:
SELECT
X.EmployeeID,
X.EmployeeName
FROM
LASRLIB.MyTable X
UNION
SELECT
0,
'EMPTY ROW'
FROM
LASRLIB.MyTable X (obs=1)
WORKED!
As I can recall, SELECT requires a FROM clause.
So you might need to refer to a row stored in an existing table, rather than hard code the values.
Thanks @LinusH
I ended up referencing the table and then just capping the select statement to a single row to avoid multiple entries going into the table:
SELECT
X.EmployeeID,
X.EmployeeName
FROM
LASRLIB.MyTable X
UNION
SELECT
0,
'EMPTY ROW'
FROM
LASRLIB.MyTable X (obs=1)
WORKED!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.