Exploring, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

week calculation is SAS VA

Accepted Solution Solved
Reply
Contributor
Posts: 39
Accepted Solution

week calculation is SAS VA

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


Accepted Solutions
Solution
‎02-13-2017 08:05 PM
Contributor
Posts: 39

Re: week calculation is SAS VA

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


All Replies
New Contributor
Posts: 4

Re: week calculation is SAS VA

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

Solution
‎02-13-2017 08:05 PM
Contributor
Posts: 39

Re: week calculation is SAS VA

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

Contributor
Posts: 39

Re: week calculation is SAS VA

Hi,

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

 

Thanks

 

Rita

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 226 views
  • 0 likes
  • 2 in conversation