| Date: | Mon, 15 Jun 2009 02:46:22 -0400 |
| Reply-To: | Francois van der Walt <francoisw@GJI.COM.AU> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Francois van der Walt <francoisw@GJI.COM.AU> |
| Subject: | Re: Auto variable for every month |
|---|
Dear Dan,
Your code:
>data _null_;
> call symput('previous_month', substr(put(today(),yymmddn8.),1,6));
>run;
>
Does it not in fact give this month, and not the previous month? Can you
change it so that it priovide it for the month before?
Kind Regards
Francois
On Sun, 14 Jun 2009 20:57:20 -0700, Daniel Nordlund
<djnordlund@VERIZON.NET> wrote:
>> -----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
|