BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
VAinTestMode
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
VAinTestMode
Calcite | Level 5

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!

View solution in original post

2 REPLIES 2
LinusH
Tourmaline | Level 20

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.

Data never sleeps
VAinTestMode
Calcite | Level 5

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!

SAS Innovate 2025: Register Now

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!

Tips for filtering data sources in SAS Visual Analytics

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.

Discussion stats
  • 2 replies
  • 1792 views
  • 0 likes
  • 2 in conversation