To run SQL code in SAS you need to use PROC SQL.
You need to make sure your SQL is compatible with SAS. Every implementation of SQL has it own distinct features and quirks.
The main issue with your posted code is the strange text at the end of one of the lines. Perhaps the SQL implementation that was used to run that code in the past allowed some type of "end of line" commenting and those double dashes are the trigger for that? I do not like end of line comments in general, you should place the comments before the code they are describing if you want to make it easier for humans to read the code.
Another issue is why would you run code like that without directing the output to a dataset. If you want to print the data, like that first query, then just use PROC PRINT and skip SQL completely.
Also to reference a dataset from a library you use only one period between the libref and the member name.
Also if you have month day and year why not just make an actual DATE variable?
proc sql;
create table copy_of_raw as
select * from try.a_RAW ;
create table raw_with_final as
select distinct
'11111' as ID
, a.SUBJID
/* study team need DOB */
, mdy( b.DOB_M , b.DOB_D , b.DOB_Y) as DOB format=date9.
, a.car as type
, a.g6m as month
, a.g2yr as 24month
, a.g1yr as 12month
, a.g10yr as decade
from try.a_RAW a
join try.FINAL b
on b.ID = '11111'
and a.SNO = b.SNO
;
quit;
... View more