LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (September 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 13 Sep 2004 10:49:47 GMT
Reply-To:     julierog@ix.netcom.com
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Roger Lustig <trovato@VERIZON.NET>
Subject:      Re: Extracting Quarter from date
Content-Type: text/plain; charset=us-ascii; format=flowed

Another way to go: quarter=intnx('quarter',date,0); format quarter yyq4.; run;

This creates a variable with value representing the first day in DATE's quarter. Could be handy if working with otherwise-ordered data.

Roger

MOORTHY Easwara wrote:

> Hi Pal, > > > > You just neer to remove the quarter function. > > > > With QTR function, You are trying to apply the format YYQ4. to the resultant > value (i.e 1,2,3,4), which SAS treats as negative > years(-0001,-0002,-0003,-0004). > > Your flow : > > > > Quarter=qtr(Jan 1 1999) > results 1 (1st quarter), and then you are applying > the format yyq4. to 1. > > > > So, just say > > > > data x; set y; > > format quarter yyq4. ; > > quarter = date; > > run; > > > > Cheerz > Easwara > > > > > > > > -----Original Message----- > From: Microstructure [mailto:randistan69@HOTMAIL.COM] > Sent: Monday, September 13, 2004 12:10 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Extracting Quarter from date > > > > I have dates in the format of yymmdd8. I want to have a separate > > variable of quarters...My code is > > > > data x; set y; > > format quarter yyq4. ; > > quarter = qtr(date); > > run; > > > > All that this code does is 60Q1 for all the dates in my file...the > > dates are from Jan 1 1999 to 31 dec 2003...so there should be 20 > > quarters...PLEASE help


Back to: Top of message | Previous page | Main SAS-L page