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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: