BookmarkSubscribeRSS Feed
Pandu2
Obsidian | Level 7
Hi All,
I Hope you all doing Great.
I require some assistance from you on how to use today's date in filter data tab in query builder. Any help would be greatly appreciated. Thanks in advance.
10 REPLIES 10
ChrisNZ
Tourmaline | Level 20

T1.date  is not a SAS date it seems? Why? You are making your life harder if you don't store a SAS date.

 

202210 this refers year and date 

I only see year and month?

 


. That value needs to be changed on daily basis 

Why change daily if you just filter on month?

Pandu2
Obsidian | Level 7
It is T1.xyz it was already stored in a table so I'm just fetching the data by using the condition in filter the data tab i.e
T1.xyz = abcd it refers year and date so whenever the system date hits new week the date should change accordingly.
Thanks.
ChrisNZ
Tourmaline | Level 20

I suppose you could use something like

where T1.Fiscalweek = year(today()) * 100 + week(today())

Check the week() function to see options about how the week is calculated

Pandu2
Obsidian | Level 7
Can't be thankful for your assistance. This is working nicely but needs to ensure whether it will change the date whenever the system date hits new week.
ChrisNZ
Tourmaline | Level 20

Try with a different date instead of today().

Try '14mar2022'd for example.

 

Did you read about the week () function to ensure you have to appropriate option in place?

Pandu2
Obsidian | Level 7
.
Kurt_Bremser
Super User

@Pandu2 wrote:
I tried by providing different dates but I found something strange. Feb 28th started on Monday and the week ended on 6th March for this entire week it should give the FW as 09 but from 28th Feb to 05Th March it is giving as 09. For 06th March it is giving the FW as 10th even though 6th was part of old week.

Study the documentation (Maxim1) of the WEEK Function . It provides an additional parameter (called "descriptor" in the doc) which controls when the week begins, and how to treat incomplete weeks at the beginning of the year.

Pandu2
Obsidian | Level 7
.
Kurt_Bremser
Super User

TRY IT. (Maxim 4)

 

Run this:

data check;
do date = '01jan2022' to today();
  week = week(date);
  output;
end;
format date yymmdd10.;
run;

and look at the dataset to see if it provides the week numbers you expect. If this is not the case, post examples and the numbers you expect instead.

Reeza
Super User

Please do not delete the contents of your post. The purpose of the forum is to create a searchable history for others as well.

And when your questions are answered please select the appropriate response that answered your question and select that as the solution. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 600 views
  • 1 like
  • 4 in conversation