BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
izzytetteh24
Calcite | Level 5

%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).

1 ACCEPTED SOLUTION

Accepted Solutions
Sajid01
Meteorite | Level 14

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

----

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 %let val_date=16MAR2021;
74 %put &val_date.;
16MAR2021
---
As rightly pointed by @PaigeMiller you must assign a value to the macro variable other wise your program will  not work.
If you get a chance please read this paper. 
https://support.sas.com/resources/papers/proceedings17/1516-2017.pdf 

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
izzytetteh24
Calcite | Level 5
Well shouldn't I assign it to &val_date? That would make it work right?
PaigeMiller
Diamond | Level 26

@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"?

--
Paige Miller
Sajid01
Meteorite | Level 14

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

----

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 %let val_date=16MAR2021;
74 %put &val_date.;
16MAR2021
---
As rightly pointed by @PaigeMiller you must assign a value to the macro variable other wise your program will  not work.
If you get a chance please read this paper. 
https://support.sas.com/resources/papers/proceedings17/1516-2017.pdf 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 15527 views
  • 1 like
  • 3 in conversation