Dear SAS experts
I have made a simplified example of the problem I am facing.
Following the code in the bottom SAS reports:
SYMBOLGEN: Macro variable J resolves to 2008
SYMBOLGEN: Macro variable L resolves to 3
bef20083
SYMBOLGEN: Macro variable J resolves to 2008
SYMBOLGEN: Macro variable L resolves to 6
bef20086
SYMBOLGEN: Macro variable J resolves to 2008
SYMBOLGEN: Macro variable L resolves to 9
bef20089
SYMBOLGEN: Macro variable J resolves to 2008
SYMBOLGEN: Macro variable L resolves to 12
bef200812
SYMBOLGEN: Macro variable J resolves to 2009
SYMBOLGEN: Macro variable L resolves to 3
bef20093
SYMBOLGEN: Macro variable J resolves to 2009
SYMBOLGEN: Macro variable L resolves to 6
bef20096
SYMBOLGEN: Macro variable J resolves to 2009
SYMBOLGEN: Macro variable L resolves to 9
bef20099
SYMBOLGEN: Macro variable J resolves to 2009
SYMBOLGEN: Macro variable L resolves to 12
I would like to include a 0 in front of 3, 6 and 9, but it is not included based on my code. Can anyone help me resolve this issue.
Thank you
Here is the code:
Ah, of course. Thank you very much!
You can also simplify the code by using SAS date values, the INTNX function and a date format:
%macro newtest;
%do i=0 %to 7;
%put bef%sysfunc(intnx(qtr,'01JAN2008'd,&i,e),yymmn.);
%end;
%mend;
%newtest
@FreelanceReinh wrote:
You can also simplify the code by using SAS date values, the INTNX function and a date format:
%macro newtest; %do i=0 %to 7; %put bef%sysfunc(intnx(qtr,'01JAN2008'd,&i,e),yymmn.); %end; %mend; %newtest
@mgrasmussen this is an important point. You are always better off working with dates as actual valid numeric SAS dates as shown above by @FreelanceReinh, rather than working with them as text strings that have to be pulled apart, modified and combined somehow
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.