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

Hi, 

 

Can anyone let me know why this calculated field is not producing an output.

DATE_day is formated as date/time and that is why I am using TreatAs, otherwise VA doesn't accept the function:

 

WeekNumber(TreatAs(_Date_, 'DATE_day'n))

 

 

Any help would be really appreciated.

 

cheers

 

Rita

1 ACCEPTED SOLUTION

Accepted Solutions
rmalcata
Quartz | Level 8

Hi Tobias,

Thank you for the reply.

The calculation produced something but not really what I expected.

week calculation error.PNG

 

This was the formula that I used as you described:

WeekNumber(DatePart('DAY_DATE'n))

 

Is there anything that I am doing wrong?! I am using a calculated field.

 

Cheers,

 

Rita

Rita

View solution in original post

3 REPLIES 3
TobiasH
Fluorite | Level 6

Hi Rita,

 

you may also try to use the function Datepart() which extracts the date information from a date/time number:

WeekNumber(Datepart(DATE_day))

 

As I understood the TreatAs function just converts a number (like 1) to a date/time information (01.01.1960 00:00:00) and the function weeknumber needs a date only information.

 

If your DATE_day is a number than you have to convert it first to a date/time (with treatas) and then extract the date part.

 

Let me know if I'm wrong!

 

Best,

 

Tobias

rmalcata
Quartz | Level 8

Hi Tobias,

Thank you for the reply.

The calculation produced something but not really what I expected.

week calculation error.PNG

 

This was the formula that I used as you described:

WeekNumber(DatePart('DAY_DATE'n))

 

Is there anything that I am doing wrong?! I am using a calculated field.

 

Cheers,

 

Rita

Rita

rmalcata
Quartz | Level 8

Hi,

The calcualtion was correct. I just forgot to change the aggregation to min, avg or max. the sum doesn't work.

 

Thanks

 

Rita

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 1367 views
  • 0 likes
  • 2 in conversation