BookmarkSubscribeRSS Feed
shubha1babu
Calcite | Level 5

Hi All,

 

I want to use a Date variable dynamically in a text input object. 

Requirement is, when user will select the any date from text input based on the selected date, no of day difference should come for all dates in a list table like below.

 

Text input 10/10/2024

 

Date                 Day Diff

08/10/2024       2

07/10/2024       3

06/10/2024       4

05/10/2024       5

04/10/2024       6

 

Hope some one will provide the solution.

 

Regards,

S Bakshi

2 REPLIES 2
Stu_SAS
SAS Employee

Hey @shubha1babu! You can achieve this using a combination of a parameter and an expression. Since SAS dates are the number of days since Jan 1st 1960, you can subtract two dates from each other to get the number of days between them. In Visual Analytics, this works the exact same way. Let's get started.

 

  1. Create a new text input control and add it to your report
  2. Create a new character parameter and name it "Date (DD/MM/YYYY)". This will give users a nice queue on what they should enter in the text box. You'll see how this comes into play in the next step.
  3. Assign the character parameter to the text input control. Note it says "Enter Date (DD/MM/YYYY)".
  4. Create a new expression and call it "Date Diff", then assign it a format of Float with 0 decimal places.  
    Parse('Date (DD/MM/YYYY)'p, 'DDMMYY10') - 'Date'n
    This expression says to read the value the user entered as a date in DDMMYY10 format, then subtract it from the date in the table
  5. Add it to your table and you're done!

If for some reason you run into a problem subtracting the date, try using "TreatAs(_number_, 'Date'n)" instead.

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 2 replies
  • 691 views
  • 1 like
  • 3 in conversation