Help using Base SAS procedures

macro var not being resolved

Accepted Solution Solved
Reply
Super Contributor
Super Contributor
Posts: 444
Accepted Solution

macro var not being resolved

hello,

 

%LET dte = %sysfunc(intnx(month, &today, -27));

 

i am running a  query with a pass  through connection and when  using 

where>'01Mar2015'd  everything looks fine but  if i use a macro variable

where>&dte then i get  the warning 'symbolic reference dte not being  resolved" which leads to an error

 

i also  tried to  double  qoute this macro var and again  the same  warning and  error

Any idea  why is this  happening?

 


Accepted Solutions
Solution
‎06-28-2017 01:36 PM
Trusted Advisor
Posts: 1,932

Re: macro var not being resolved

You don't need the double quotes around &month_27

 

This macro variable is resolved for me in my application with my database and works as expected.

View solution in original post


All Replies
Trusted Advisor
Posts: 1,932

Re: macro var not being resolved

Does &today have a value?

Super Contributor
Super Contributor
Posts: 444

Re: macro var not being resolved

Posted in reply to PaigeMiller

yes  it does  ,sorry

 

%LET today = %sysfunc(today());

Trusted Advisor
Posts: 1,932

Re: macro var not being resolved

Then we need to see a larger section of your code so we can understand the entire usage.

Super User
Posts: 5,516

Re: macro var not being resolved

Without seeing more of your code, this is a shot in the dark.  Try adding a %GLOBAL statement before assigning a value to DTE:

 

%global dte;

%let dte = %sysfunc ...........;

Super Contributor
Super Contributor
Posts: 444

Re: macro var not being resolved

Posted in reply to Astounding

 

%global  not working  either  Smiley Sad

the code  works fine  if  i  use         tab2.CREATION_DATE >="01MAR2015"d but not if i use the macro var below  and it resolves fine everywhere out  of the  query but not in the  query below

 

 


%LET today = %sysfunc(today());
%LET month_27 = %sysfunc(intnx(month, &today, -27));

%put  &month_27;

 

CREATE TABLE clkb_base AS
SELECT x,y,z
 
FROM tab1
 JOIN tab2  ON tab1.ADDR_ENTITY_ID = tab2.CUSTOMER_ID
 JOIN tab3. ON tab1.ID = tab3.ENTITY_ID
  ........................
  .........................
WHERE  tab2.CREATION_DATE >="&month_27"
QUIT;

Solution
‎06-28-2017 01:36 PM
Trusted Advisor
Posts: 1,932

Re: macro var not being resolved

You don't need the double quotes around &month_27

 

This macro variable is resolved for me in my application with my database and works as expected.

Super Contributor
Super Contributor
Posts: 444

Re: macro var not being resolved

Posted in reply to PaigeMiller

yea,i also tried  the same  code  on EG SAS and  works  but did not on PC SAS so definately not a  syntax issue

 

thank you

 

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 259 views
  • 0 likes
  • 3 in conversation