Hi i was wanting to filter based on 'MONYYYY' date condition in the where step
I know about the default date filter condition 'DDMONYYY'd . But that does not help here .
any suggestions ?
eg:
'AUG2018'
'SEP2018'
You can also use
where month(yourdate) = 8 and year (yourdate) = 2018;
How are you trying to filter your data?
You need to either use the formatted value or change your filter to use a full date.
where '01Jun2019'd <= date_filtered <= '30Jun2019'd;
where vvalue(date_filtered) = '01JUN'; *check case matches here;
where put(date_filtered, monyy5.) = '01JUN';*case must match, text comparison;
@dennis_oz wrote:
Hi i was wanting to filter based on 'MONYYYY' date condition in the where step
I know about the default date filter condition 'DDMONYYY'd . But that does not help here .
any suggestions ?
eg:
'AUG2018'
'SEP2018'
@dennis_oz wrote:
Hi i was wanting to filter based on 'MONYYYY' date condition in the where step
I know about the default date filter condition 'DDMONYYY'd . But that does not help here .
any suggestions ?
eg:
'AUG2018'
'SEP2018'
Your use of quotes around the date confuses the matter. SAS does not display the quotes when you look at dates, so why are you showing the quotes to us?
Are these numeric variables, formatted to appear as AUG2018? Or are they character strings in a character variable?
In either case, you can filter using a WHERE clause, but to do this properly we need to know if they are character or numeric variables.
@dennis_oz wrote:
they are numeric variables that habe the format applied to them.
The first line of code from @Reeza should work. Probably his other lines of code work as well.
You can also use
where month(yourdate) = 8 and year (yourdate) = 2018;
Maxim 3: Know Your Data.
Is the variable in question character or numeric? If it is numeric, it has the monyy7. format assigned and contains a valid SAS date value; you can directly compare it to a date literal.
If it is character, you need to convert it first.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.