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

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)

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

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

1 REPLY 1
Patrick
Opal | Level 21

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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