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

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'

1 ACCEPTED SOLUTION
6 REPLIES 6
Reeza
Super User

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'


 

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
dennis_oz
Quartz | Level 8
they are numeric variables that habe the format applied to them.
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
Kurt_Bremser
Super User

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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 6 replies
  • 2339 views
  • 3 likes
  • 4 in conversation