I'm trying to create macros in sql and I'm also trying to create a table and that my code and the error that I got
proc sql ;
create table &visit.2 as
select count (distinct internal_visit_id) AS counttime, 1360 AS TIME_POINT_CONTRACTED
from &visit.1
where Earliest_Visit_Date ne .
select counttime , TIME_POINT_CONTRACTED into :counttimet, :timecont from &visit.2;
quit;
You’re missing the semicolon to end your first SELECT statement.
if the purpose of the second select statement is to restrict the data then it is 1) out of order and 2) likely needs parentheses:
Or you are missing a semicolon between two separate queries
proc sql ; create table &visit.2 as select count (distinct internal_visit_id) AS counttime, 1360 AS TIME_POINT_CONTRACTED from &visit.1 where Earliest_Visit_Date ne . ; select counttime , TIME_POINT_CONTRACTED into :counttimet, :timecont from &visit.2; quit;
I find that you can prevent some of these types of mistakes by getting in the habit of formatting multi-line statements similar to how you would format a multiple line DO/END block.
If 0=nmiss(x,y) then do;
diff = x-y ;
percent = diff/y ;
end;
That is place the termination code (the semi-colon) on the last line by itself.
proc sql ;
create table &visit.2 as
select count (distinct internal_visit_id) AS counttime
, 1360 AS TIME_POINT_CONTRACTED
from &visit.1
where Earliest_Visit_Date ne .
;
select counttime , TIME_POINT_CONTRACTED into :counttimet, :timecont
from &visit.2
;
quit;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.