From: Gerhard Hellriegel on 9 Mar 2010 09:53 Think one problem is: it is really very unimportant how the date values are formatted, the content is always the same! What I don't understand: what is PERIOD? In your example, the PERIOD seems to be always a date in january 2010, independant from start and end!? If you need februray data, independant of the year, why not using the month-function for that? That returns always 2 for february and that you can use for subsetting across all years in your data... Gerhard On Tue, 9 Mar 2010 09:35:28 -0500, Nathaniel Wooding <nathaniel.wooding(a)DOM.COM> wrote: >Joinee While I can suspect where the problem lies, could you post (to the group, not just to me) the actual code that you used. That would help a lot. Nat Wooding From: sasbond1981 sasbond1981 [mailto:sasbond1981(a)gmail.com] Sent: Tuesday, March 09, 2010 9:14 AM To: Nathaniel Wooding (Services - 6) Cc: SAS-L(a)listserv.uga.edu; SAS-L-request(a)listserv.uga.edu Subject: Re: new joinee Hi, need suggestion please.. Suppose I have a dataset containing two variables "Start_Date and End_Date" and here I need to create a variable called "period". Here the start and end dates were in Datetime format and I took only datepart by "datepart" function and formated it as date9. And created "Period" variable by giving some logic as " MDY(month(today()),1,year(today()))-1 " which will give value as "FEB2010" (which is Monyy7. format). So now based on this period variable I need to pull only the FEB month data from years of data. Actually the data contains two years (historical) data till last month. example: START_DATE END_DATE PERIOD 01FEB2010 01FEB2010 JAN2010 01FEB2010 02FEB2010 JAN2010 16JUL2009 16JUL2009 JAN2010 19DEC2009 20DEC2009 JAN2010 21JAN2010 22FEB2010 JAN2010 26FEB2010 26FEB2010 JAN2010 30JAN2010 30JAN2010 JAN2010 31DEC2009 31DEC2009 JAN2010 the above is the sample data... now what I need is based on this period I need to pull only Feb dates starting from 01FEB2010 and ending of 31FEB2010. So in simple I want FEB data only. START_DATE is in date9. format END_DATE is in date9. format Period is in Monyy7. format I tried with between and >= and <= and etc etc... but it is not workin for me... please give me ur idea on this... Cheers, 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.
From: sasbond1981 sasbond1981 on 9 Mar 2010 10:06 My problem is i created a variable called 'Period' by the logic "MDY(month(today()),1,year(today()))-1" which will return the value as FEB2010. And now the i need to pull the data based on this period variable (FEB2010) from the 5 years of data. Here this data contains 5 years of data and I only need Feb2010 data only. And here i have two variabels Start_date and Class_Date and I wrote like this Month(period) between month(datepart(start_date)) and month(datepart(end_date)) but some how its not working fine... is dre any other way to get the data please....
From: sasbond1981 sasbond1981 on 9 Mar 2010 10:09 sorry its start_date and end_date....
From: Nathaniel Wooding on 9 Mar 2010 10:24 Please post the actual code that you wrote, not a paraphrase of it. Nat -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of sasbond1981 sasbond1981 Sent: Tuesday, March 09, 2010 10:06 AM To: SAS-L(a)LISTSERV.UGA.EDU Subject: Re: Selecting dates in a period. Was RE: new joinee My problem is i created a variable called 'Period' by the logic "MDY(month(today()),1,year(today()))-1" which will return the value as FEB2010. And now the i need to pull the data based on this period variable (FEB2010) from the 5 years of data. Here this data contains 5 years of data and I only need Feb2010 data only. And here i have two variabels Start_date and Class_Date and I wrote like this Month(period) between month(datepart(start_date)) and month(datepart(end_date)) but some how its not working fine... is dre any other way to get the data please.... 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.
From: sasbond1981 sasbond1981 on 9 Mar 2010 10:40 I have dataset "master" as below START_DATE END_DATE 01FEB2010 01FEB2010 01FEB2010 02FEB2010 16JUL2009 16JUL2009 19DEC2009 20DEC2009 21JAN2010 22FEB2010 26FEB2010 26FEB2010 30JAN2010 30JAN2010 31DEC2009 31DEC2009 And now i need to create a varable called "period" Data Master2; Set Master; period=MDY(month(today()),1,year(today()))-1; run; and now the Master2 dataset contains as below START_DATE END_DATE PERIOD 01FEB2010 01FEB2010 JAN2010 01FEB2010 02FEB2010 JAN2010 16JUL2009 16JUL2009 JAN2010 19DEC2009 20DEC2009 JAN2010 21JAN2010 22FEB2010 JAN2010 26FEB2010 26FEB2010 JAN2010 30JAN2010 30JAN2010 JAN2010 31DEC2009 31DEC2009 JAN2010 And now I need to pull only Feb month Data as given below Proc Sql; create table Master3 as select * from Master2 where month(period) between month(start_date) and month(end_date); quit; but some this logic is not working for me.... i mean its pulling all the observations rather pulling only feb dates.... Cheers,
|
Pages: 1 Prev: Selecting dates in a period. Was RE: new joinee Next: PROC FORMAT |