From: renxue on
hello everyone;
recently I am writting a macro,I want to generate two variable
txc_today txc_yesterday .
both variables are used as table names;
here is my macro program:


%macro mm;

%global txc_today txc_yesterday weekday;
%let weekday=&sysday;
%let txc_today=%sysfunc(date(),yymmddn8.) ;
%let txc_yesterday=%sysfunc(intnx(1 ,&txc_today,-1));

%put &txc_today &txc_yesterday &weekday ;

%mend mm;
%mm;


I run this program everyday.
but I found a question .
for example;

today is 2009-12-01 .
I format this date to 20091201
but I run the program above ,it is 20091200.
it is too funny.


how can I get a result of yesterday to be 20091130


so I have another question .
if today is 2010-03-01
how can I get yesterday to be 20100228




thank you !!!
From: Chris Jones on
On 1 Dec, 11:06, renxue <zijun2...(a)gmail.com> wrote:
> hello everyone;
> recently I am writting a macro,I want to generate two variable
> txc_today txc_yesterday   .
> both variables are used  as  table names;
> here is my macro program:
>
> %macro mm;
>
> %global txc_today txc_yesterday weekday;
> %let weekday=&sysday;
> %let txc_today=%sysfunc(date(),yymmddn8.)  ;
> %let txc_yesterday=%sysfunc(intnx(1 ,&txc_today,-1));
>
> %put &txc_today &txc_yesterday &weekday  ;
>
> %mend mm;
> %mm;
>
> I run this program everyday.
> but I found a question .
> for example;
>
> today is 2009-12-01 .
> I format this date to 20091201
> but I run the program above ,it is 20091200.
> it is too funny.
>
> how can I get a result of yesterday to be 20091130
>
> so  I have another question .
> if today is 2010-03-01
> how can I get yesterday to be 20100228
>
> thank you !!!

Firstly, you don't need to wrap it in a %MACRO / %MEND block.

Try this:

%let txc_today=%sysfunc(date(),yymmddn8.) ;
%let txc_yesterday=%sysfunc(intnx(1 ,%SYSFUNC(date()),-1));

From: renxue on
On Dec 1, 7:09 pm, Chris Jones <chris...(a)gmail.com> wrote:
> On 1 Dec, 11:06, renxue <zijun2...(a)gmail.com> wrote:
>
>
>
> > hello everyone;
> > recently I am writting a macro,I want to generate two variable
> > txc_today txc_yesterday   .
> > both variables are used  as  table names;
> > here is my macro program:
>
> > %macro mm;
>
> > %global txc_today txc_yesterday weekday;
> > %let weekday=&sysday;
> > %let txc_today=%sysfunc(date(),yymmddn8.)  ;
> > %let txc_yesterday=%sysfunc(intnx(1 ,&txc_today,-1));
>
> > %put &txc_today &txc_yesterday &weekday  ;
>
> > %mend mm;
> > %mm;
>
> > I run this program everyday.
> > but I found a question .
> > for example;
>
> > today is 2009-12-01 .
> > I format this date to 20091201
> > but I run the program above ,it is 20091200.
> > it is too funny.
>
> > how can I get a result of yesterday to be 20091130
>
> > so  I have another question .
> > if today is 2010-03-01
> > how can I get yesterday to be 20100228
>
> > thank you !!!
>
> Firstly, you don't need to wrap it in a %MACRO / %MEND block.
>
> Try this:
>
> %let txc_today=%sysfunc(date(),yymmddn8.)  ;
> %let txc_yesterday=%sysfunc(intnx(1 ,%SYSFUNC(date()),-1));

thank you for you reply .
I try this way before.
the result is :

20091201 18231 Tuesday


I want the result to be :

20091201 20091130 Tuesday
From: zhang3stone on
Just don't forget to format the later

%let txc_today=%sysfunc(date(),yymmddn8.) ;
%let txc_yesterday=%sysfunc(intnx(1 ,%SYSFUNC(date()),-1),yymmddn8.);
From: Ram on
On Dec 1, 5:21 am, renxue <zijun2...(a)gmail.com> wrote:
> On Dec 1, 7:09 pm, Chris Jones <chris...(a)gmail.com> wrote:
>
>
>
>
>
> > On 1 Dec, 11:06, renxue <zijun2...(a)gmail.com> wrote:
>
> > > hello everyone;
> > > recently I am writting a macro,I want to generate two variable
> > > txc_today txc_yesterday   .
> > > both variables are used  as  table names;
> > > here is my macro program:
>
> > > %macro mm;
>
> > > %global txc_today txc_yesterday weekday;
> > > %let weekday=&sysday;
> > > %let txc_today=%sysfunc(date(),yymmddn8.)  ;
> > > %let txc_yesterday=%sysfunc(intnx(1 ,&txc_today,-1));
>
> > > %put &txc_today &txc_yesterday &weekday  ;
>
> > > %mend mm;
> > > %mm;
>
> > > I run this program everyday.
> > > but I found a question .
> > > for example;
>
> > > today is 2009-12-01 .
> > > I format this date to 20091201
> > > but I run the program above ,it is 20091200.
> > > it is too funny.
>
> > > how can I get a result of yesterday to be 20091130
>
> > > so  I have another question .
> > > if today is 2010-03-01
> > > how can I get yesterday to be 20100228
>
> > > thank you !!!
>
> > Firstly, you don't need to wrap it in a %MACRO / %MEND block.
>
> > Try this:
>
> > %let txc_today=%sysfunc(date(),yymmddn8.)  ;
> > %let txc_yesterday=%sysfunc(intnx(1 ,%SYSFUNC(date()),-1));
>
> thank you for you reply .
> I try this way before.
> the result is :
>
> 20091201 18231 Tuesday
>
> I want  the result to be :
>
> 20091201   20091130  Tuesday- Hide quoted text -
>
> - Show quoted text -

Try this:

%let txc_today=%sysfunc(date(),yymmddn8.) ;
%let txc_yesterday=%sysfunc(putn(%sysfunc(date()) - 1, yymmddn8.));
%let day_of_week =%sysfunc(date(),Downame.);

%put &txc_today &txc_yesterday &day_of_week. ;