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

Hello everyone,

 

Is it also possible in SAS VIYA to display the last date of the month? I currently have a table with various dates and values. However, I only want to see the last day of the respective month. Is this possible in SAS VIYA?

 

In any case, thank you for the responses.

 

Regards, Hans

 

Knipsel.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

You can calculate the last day of the month based on some date using this expression. Where myDate is the Datum dataitem in your example. Depending on your version of Visual Analytics you can subtract a number directly from a date, otherwise you need to use the TreatAs function.

DateFromMDY(
    Mod(Month(myDate), 12) + 1
    , 1
    , Year(myDate) + Trunc(Month(myDate) / 12)
)
- 1

Once you have the new data item, you can use it in a filter to specify some like 
datum = last_day_of_month

View solution in original post

5 REPLIES 5
BrunoMueller
SAS Super FREQ

We would need more information like:

  • are you writing a SAS program
  • are you using Visual Analytics
  • Is it the last day of the month as of today or something else
HansSteenhuis
Calcite | Level 5

thank you for your response.

 

I'm using Visual Analytics (VIYA). It concerns the last day of the month.

 

I only want to see the dates highlighted in yellow (see image).

 

 

BrunoMueller
SAS Super FREQ

You can calculate the last day of the month based on some date using this expression. Where myDate is the Datum dataitem in your example. Depending on your version of Visual Analytics you can subtract a number directly from a date, otherwise you need to use the TreatAs function.

DateFromMDY(
    Mod(Month(myDate), 12) + 1
    , 1
    , Year(myDate) + Trunc(Month(myDate) / 12)
)
- 1

Once you have the new data item, you can use it in a filter to specify some like 
datum = last_day_of_month

HansSteenhuis
Calcite | Level 5

Thank you very much. It worked!

Tom
Super User Tom
Super User

@HansSteenhuis wrote:

thank you for your response.

 

I'm using Visual Analytics (VIYA). It concerns the last day of the month.

 

I only want to see the dates highlighted in yellow (see image).

 

 


One simple way to test if a value is the last day of the month is to check if the next day is a different month.

In normal SAS code such a test could be :

month(datum) ne month(datum+1)

Which will be TRUE when DATUM is the last day of a month.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 769 views
  • 0 likes
  • 3 in conversation