Date: Tue, 23 Sep 2008 09:04:12 -0400
Reply-To: Nathaniel.Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject: Re: creating variables based on dates range
In-Reply-To: <efc56cf1-a4f8-4351-8a8a-dbcd0725c4b5@d1g2000hsg.googlegroups.com>
Content-Type: text/plain; charset="US-ASCII"
Dina
Try the following code:
Data period;
informat CustomerID 8. date $10. article $3. ;
input CustomerID Date Article ;
cards;
1 02.01.2008 KTM
1 03.01.2008 FTM
1 18.01.2008 KTM
1 02.02.2008 BBS
run;
proc print;run;
Data period;* I am doing this in a second data step based on the assumption
that date is stored
as a character string and not as a sas date variable. If date is actually a
sas date variable,
then Period = put( Month( Date ) , Worddate9. );
set period;
Period = put( Month( input ( Date , ddmmyy10. ) ) , Worddate9. );
run;
Proc Print;
run;
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
"edina.cmanjcanin
@gmail.com"
<edina.cmanjcanin To
@GMAIL.COM> SAS-L@LISTSERV.UGA.EDU
Sent by: "SAS(r) cc
Discussion"
<SAS-L@LISTSERV.U Subject
GA.EDU> creating variables based on dates
range
09/23/2008 08:45
AM
Please respond to
"edina.cmanjcanin
@gmail.com"
<edina.cmanjcanin
@GMAIL.COM>
Hello
I need to create new variable "Period" based on observation Dates.
To be more accurate, if observation Dates is in time period (eg. from
01.01.2008 - 01.02.2008 ) to add new values "Januar" to that
observation so on...
example
my data
Customer ID | Date | Article
1 02.01.2008 KTM
1 03.01.2008 FTM
1 18.01.2008 KTM
1 02.02.2008 BBS
2
... ........ ...
1455 05.01.2008 OEK
...
results should look like
Customer ID | Date | Article | Period
1 02.01.2008 KTM Januar
1 03.01.2008 FTM Januar
1 18.01.2008 KTM Januar
1 02.02.2008 BBS Februar
2
... ........ ...
1455 05.05.2008 OEK May
After that I will group my data by period, and try to find how many
articles was bought in Januar or some other period.
Thx for your help
Dina
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and/or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.