sas >> Week function

by Eric.J.Bush » Tue, 01 Mar 2005 23:08:33 GMT

According to the on-line documentation, the week function has two
arguements - WEEK(<sas_date>, <descriptor>). The descriptor can be U,
V, or W. However when I include the second arguement I get errors in my
log that "V" is uninitialized. Any help in using the week function with
descriptor=V would be appreciated.

My data is:
data week;
input group $ date;
informat date mmddyy6.;
datalines;
A 030804
B 031004
C 031604
;
run;

My code is:
data AGid; set week;
weekofyear=week(date, v);

Thanks,
Eric Bush
Epidemiologist


sas >> Week function

by ghellrieg » Tue, 01 Mar 2005 23:26:23 GMT


Try to set the v in ' or ", like week(xy,"V");






sas >> Week function

by art297 » Tue, 01 Mar 2005 23:27:19 GMT

Eric,

Try adding quotes:

data AGid; set week;
weekofyear=week(date, 'v');
run;

Art
------
On Tue, 1 Mar 2005 08:08:33 -0700, Eric Bush < XXXX@XXXXX.COM >




Week Function

by mditconsult » Thu, 05 Nov 2009 02:39:13 GMT

I like to see my week starts as Week - 1 from middle of year.

Say ---

Week=week(date); gives me below for time period 01jun2008 - 31may2009 ...

Date Week

27jun2008 22
14Aug2008 32
09Jan2009 09


But i would like to arrange in order for time period 01jun2008 - 31may2009.

Date Week

27jun2008 03
14Aug2008 13
09Jan2009 33 ....

Regards & Thanks
Jassi


Week Function

by iebupdte » Thu, 05 Nov 2009 02:50:44 GMT

I think you need INTCK function.

data _null_;
input date:date9.;
retain base '01Jun2008'd;
week = intck('week',base,date);
format date base date9.;
put (_all_)(=);
cards;
27jun2008
14Aug2008
09Jan2009
;;;;
run;








Week Function

by nweston » Thu, 05 Nov 2009 02:51:13 GMT

You may want to try variations of this;


data have;
input week date9.;
format week date9.;
cards;
27jun2008
14Aug2008
09Jan2009
;
run;

data want;
set have;
format wknum z2.;
wknum = intck("week","01jun08"d,week);
run;


Week Function

by ya.huang » Thu, 05 Nov 2009 03:30:48 GMT

I'm wondering why the expect result is

14Aug2008 = 13
09Jan2009 = 33

Instead of

14Aug2008 = 10
09Jan2009 = 31

Maybe there is some other rules?




31may2009.


Week Function

by iebupdte » Thu, 05 Nov 2009 03:54:41 GMT

I assumed the OP made the error calculating the expected result "by hand".






Similar Threads

1. Equivalent of the "Rollup" SQL function in SAS (and the CUBE function also)

2. need a sas function analagous to LAG function

Hello All,

I am familiar with the LAG function. It allows you to use a value of a
variable from the previous observation in hte calculation of a value of a
variable for the current observation.

What I need to to is if there is a function which allows you to take a
value of a variable in the NEXT observation and use it in operations on the
current observation. If so, what is it?

For example, I want to take the value of the variable UNIT in from the
observation that follows my current one and assign it to a new variable in
the current observation.

something like:

if unit='.' then unit1=next(unit);

I don't think "next" is what i want, but what is?

Thanks,

Randall

3. ERROR when referencing the RENAME function in the %SYSFUNC macro function

4. Reminder - last week for 2008 SAS-L award nominations

5. find nth week of a day

6. Day-of-week Date Time Format

I'm not having any luck finding the format name that is used in the PROC
CONTENTS ATTRIBUTE table for Created and Last Modified dattime
variables.  If you run a PROC CONTENTS, then you may see something like
this in the 4th row of the first table:

Created   Sunday, June 04, 2006 06:20:06 PM

When you put this into a dataset, via ODS OUTPUT ATTRIBUTE=3Dattrib;, =
then
nValue for Created is a datetime numeric, 1465064406.  I'd like to
format this value to resemble the above Day-of-Week, Date, Time
formatted value.

Anyone know this?  I've searched SAS, SAS Doc's, and SAS-L Archive, and
haven't found the answer.

Did find out about:  NLDATMw. and DTWKDATXw. , but neither give me the
above. (The former gives 04Jun06:18:20:06, while the latter gives
Sunday, June 04, 2006).

John Gerstle, MS=20
Biostatistician
Northrop Grumman
CDC Information Technological Support Contract (CITS)
NCHSTP \DHAP \HICSB \Research, Analysis, and Evaluation Section
Centers for Disease Control and Prevention

"As far as the laws of mathematics refer to reality, they are not
certain; and as far as they are certain, they do not refer to reality."

                  Albert Einstein, addressing the Prussian Acadamy of
Science, Berlin , Jan 27, 1921=20

"Boss. We've got cats."  "Meow"

7. Converting dates to weeks

8. OT: lost email and spam wave a few weeks ago