%PUT VAL_DATE=&VAL_DATE;
%PUT _global_;
PROC SQL;
CREATE TABLE WORK.NB_Prem AS
SELECT
a.ModelPlan AS Group,
MONTH(b.EXTR_ISSUE_DATE) AS Iss_Month,
SUM(b.EXTR_GROSS_PREM)*3 AS Prem
FROM WORK.BLCFSRPT AS b INNER JOIN (SaDAVArt.DAFSRPTPlanInfo AS a INNER JOIN SaDAVArt.DAFSRPT_LPRO_MAPPING ON (a.AdminPlan=Vantage_Admin_Plan)) ON b.EXTR_ADMIN_PLAN_CODE=LifePro_Coverage_ID
WHERE YEAR(b.EXTR_ISSUE_DATE)=YEAR(&VAL_DATE)
GROUP BY Group,Iss_Month
HAVING Iss_Month=MONTH(&VAL_DATE);
RUN;
QUIT;
*******program
PROC SQL;
28 CREATE TABLE WORK.NB_Prem AS
29
30 SELECT
31
32 a.ModelPlan AS Group,
33 MONTH(b.EXTR_ISSUE_DATE) AS Iss_Month,
34 SUM(b.EXTR_GROSS_PREM)*3 AS Prem
35
36 FROM WORK.BLCFSRPT AS b INNER JOIN (SaDAVArt.DAFSRPTPlanInfo AS a INNER JOIN SaDAVArt.DAFSRPT_LPRO_MAPPING ON
36 ! (a.AdminPlan=Vantage_Admin_Plan)) ON b.EXTR_ADMIN_PLAN_CODE=LifePro_Coverage_ID
37 WHERE YEAR(b.EXTR_ISSUE_DATE)=YEAR(&VAL_DATE)
_
22
WARNING: Apparent symbolic reference VAL_DATE not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER.
38 GROUP BY Group,Iss_Month
39 HAVING Iss_Month=MONTH(&VAL_DATE);
_
22
WARNING: Apparent symbolic reference VAL_DATE not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER.
*****log
I'm running into a symbolic reference warning and subsequent syntax error from the code shown in the first vignette. Clearly there shows a put macro that assigns a macro variable to field VAL_DATE. And I looked up some solutions to this issue which included creating a %put _global_; statement which also didn't work. So what am I missing? (I'm also running by selection if that makes a difference).
Hello @izzytetteh24
Well it is like this.
1. When a value is being assigned to macro variable the syntax is
%let var_name= the_value;
2, When the macro variable so created is to be used then an ampersand is prefixed. Thus to use the value of var_name, it would be &var_name.
Thus in your case assignment would be %let val_date=16MAR2021;
and will using it say %put &val_date. ;
(I gave this value as an example)
You will see something like this in the log
----
Macro variable &VAL_DATE has not been defined.
Clearly there shows a put macro that assigns a macro variable to field VAL_DATE.
That's not what %PUT does.
You can define a macro variable and assign it a value like this:
%let val_date=;
but this creates an empty macro variable, and the rest of your program still won't run properly. You have to assign it a value that will work in your program, I don't know what that would be.
@izzytetteh24 wrote:
Well shouldn't I assign it to &val_date? That would make it work right?
What do you mean? What are you referring to by "it"?
Hello @izzytetteh24
Well it is like this.
1. When a value is being assigned to macro variable the syntax is
%let var_name= the_value;
2, When the macro variable so created is to be used then an ampersand is prefixed. Thus to use the value of var_name, it would be &var_name.
Thus in your case assignment would be %let val_date=16MAR2021;
and will using it say %put &val_date. ;
(I gave this value as an example)
You will see something like this in the log
----
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.