Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro Variable Date Calculations 1

Status
Not open for further replies.

tubbsy123

Programmer
Dec 2, 2004
19
AU

Hi,

I need to populate a macro variable, filedate, with the following saturdays date. It needs to be formatted as yyyymmdd.

The following code is how far I've got.

The &filedate. variable doesn't work correctly when run using %put. I get todays date and part of the code, eg 20100223+(7-2).

I created the macro variable, &fdate., to deal with this. This still doesn't show the correct date.

When I create a new field in a data step the process works. At which point I would need to populate my original variable, %filedate.

Any ideas on how to deal with this?

Is it a symput/symget situation?


The code is as follows:

%let filedate=%sysfunc(date(),yymmddn8.)+(7-%sysfunc(weekday(%sysfunc(date()))));

%let fdate = %substr(&filedate.,1,8);

%put &filedate.;
%put &fdate.;

data work.test;
filedate=&filedate.;
fdate=&fdate.;
run;


Thanks for any help that can be provided

tubbsy123
 
If you put a %eval in front of the %sysfunc(date(),yymmddn8.)+(7-%sysfunc(weekday(%sysfunc(date()))))

so you have

%let filedate=%eval(%sysfunc(date(),yymmddn8.)+(7-%sysfunc(weekday(%sysfunc(date())))));

it should work right in that step.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top