Hello, I have a problem with the below code. %gettime is a macro which gives the 100th day after the start date and outputs a table. I would like to get table1 which gives the 100th day after date1, table2 which gives 100th day after date2...Until date12. But the code only gives me table1. I am not sure what's wrong with the code.
Thank you in advance!
%macro date;
%do i=1 %to 12;
%getdate(
start = date&i,
out = table&i);
%end;
%mend;
%date;
Not much information to work with:
Try this:
Modify the definition of the GETDATE macro and add this statement:
%local i;
Yes. Your posted code is setting I=1 then calling GETDATE. The %DO loop then increments I by 1 and tests if it is greater than 12. So GETDATE must be changing I to a value that is 11 or larger. If you tell GETDATE to use a LOCAL macro variable instead of the existing macro variable then it will not modify the variable being used for the %DO loop.
Look up CALL EXECUTE.
The documentation has an example.
@di_niu0 wrote:
Hello, I have a problem with the below code. %gettime is a macro which gives the 100th day after the start date and outputs a table. I would like to get table1 which gives the 100th day after date1, table2 which gives 100th day after date2...Until date12. But the code only gives me table1. I am not sure what's wrong with the code.
Thank you in advance!
%macro date;
%do i=1 %to 12;
%getdate(
start = date&i,
out = table&i);
%end;
%mend;
%date;
Hi
I'm happy to help. However can you give an overview of your macro getname.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.