Solved
Contributor
Posts: 47

# 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: 47

## Re: week calculation is SAS VA

Hi Tobias,

The calculation produced something but not really what I expected.

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

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: 47

## Re: week calculation is SAS VA

Hi Tobias,

The calculation produced something but not really what I expected.

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: 47

## 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.