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
Hi Tobias,
Thank you for the reply.
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
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
Hi Tobias,
Thank you for the reply.
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
Hi,
The calcualtion was correct. I just forgot to change the aggregation to min, avg or max. the sum doesn't work.
Thanks
Rita
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.