BookmarkSubscribeRSS Feed
TedCarol
Calcite | Level 5

This is killing me, if someone can help I'd be exceedingly grateful.

 

I have this program snippet.  In the last proc sql I am getting an error with the date.  Why won't it take my date variable????

 

Please help?  Error message followed by code.

 

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
NOTE: Line generated by the macro variable "DAYDATE1".
18 24NOV2016
_______
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, AND, EQ, EQT, GE, GET,
GT, GTT, LE, LET, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

 

 

 

data dates;
daydate1=intnx('day',today(),-1,'B');
FORMAT daydate1 date9.;

run;

 

proc sql;

select daydate1 into :daydate1 FROM dates;
quit;

 

proc sql;
connect to sqlsvr as sqlsvr (dsn=sqlserverp authdomain=sqlauthp);
create table work.submit as
select * from connection to sqlsvr
(select ID, store_number, min(rpt_dt) as Submit_Dt
from Appstable

group by ID, store_number
order by ID asc);
quit;

 

proc sql;
create table subday as select input(store_number,4.) as store, count(ID) as Submits
from submit where submit_dt = &daydate1
group by store_number;
quit;

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  Assuming that the variable you are selecting on is a date variable (numeric) and not a character string, you are using &daydate incorrectly. With my #1 example, I can duplicate your error message. With my #2 example, I correctly use "&daydate"d to select the row with that date.

 

cynthia

 

use_date_constant.png

Patrick
Opal | Level 21

@TedCarol

Please don't post the same question twice.

 

Cross reference to your other post 

https://communities.sas.com/t5/General-SAS-Programming/error-with-date9-field-set-equal-to-macro-var...

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 571 views
  • 0 likes
  • 3 in conversation