LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 14 Jun 2009 20:57:20 -0700
Reply-To:     Daniel Nordlund <djnordlund@VERIZON.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Daniel Nordlund <djnordlund@VERIZON.NET>
Subject:      Re: Auto variable for every month
In-Reply-To:  <200906142335.n5E9lxY3030528@malibu.cc.uga.edu>
Content-type: text/plain; charset=iso-8859-1

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On > Behalf Of Francois van der Walt > Sent: Sunday, June 14, 2009 5:36 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Auto variable for every month > > The MDY (Month day year) function in combination of today() > that provides > todays date should be able to help you out. > > Here is some code to demonstrate what I mean: > > data prevmonth; > format PrevMonthYear monyy7.; > if month(today)=1 then PrevMonthYear=mdy(12,1,year(today())-1); > else > PrevMonthYear=mdy(month(today())-1,1,year(today())); > run; > proc print; > run; > > Kind Regards > Francois > > On Fri, 12 Jun 2009 14:38:10 -0400, Suren gc > <gc_suren@YAHOO.COM> wrote: > > >I have to run a report at the first week of the month for > the previous > >month. I would like to be able to create an automatic macro > variable for > >the previous month without literally going into the SAS program and > >changing the month macrovariable for the previous month. > Month format needs > >to be in 200802 format. Any ideas would be greatly appreciated. > >Thanks, > >Suren

Here is one way to create the macro variable

data _null_; call symput('previous_month', substr(put(today(),yymmddn8.),1,6)); run;

Hope this is helpful,

Dan

Daniel Nordlund Bothell, WA USA


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