DATA Step, Macro, Functions and more

Macros variable in date parameter

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

Macros variable in date parameter

[ Edited ]

Hi

 

I have a macros variable for year defined by %let year = 2016;

 

I want to use this within a date parameter as below but I can't seem to amend my code so it works. At the moment I am getting 0 records where as if I run without the macros variable and just use 2016 instead it returns records. How can I adjust so this works?

 

data want;
set have;
where date = "01AUG&aat_year_ty."d;
run;

 

(0 records returned)

 

data want;
set have;
where date = '01AUG2016'd;
run;

 

(300 rows)


Accepted Solutions
Solution
‎12-20-2016 05:05 AM
Respected Advisor
Posts: 3,907

Re: Macros variable in date parameter

What does the SAS log tell you? Any warnings?

 

You say your macro variable is &year but then you use a macro variable &aat_year_ty in your code. Which one is the correct name.

 

The following should work:

 

%let year = 2016;

data want;
set have;
where date = "01AUG&year"d;
run;

View solution in original post


All Replies
Solution
‎12-20-2016 05:05 AM
Respected Advisor
Posts: 3,907

Re: Macros variable in date parameter

What does the SAS log tell you? Any warnings?

 

You say your macro variable is &year but then you use a macro variable &aat_year_ty in your code. Which one is the correct name.

 

The following should work:

 

%let year = 2016;

data want;
set have;
where date = "01AUG&year"d;
run;

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 212 views
  • 1 like
  • 2 in conversation