BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ChrisWoo
Obsidian | Level 7
%Let Reporting_Period = %sysfunc(Today());

%Macro REPMTH(Day=&Reporting_Period);
	%IF &day = %sysfunc(Intnx(Month,&Day,0,b)) %THEN %DO;
		%sysfunc(Intnx(Month,&Day,-2,s),MMYYN4.);
	%END;
	%ELSE %DO;
		%sysfunc(Intnx(Month,&Day,-1,s),MMYYN4.);
	%END;
%Mend;

%LET Today = %sysfunc(putn(&Reporting_Period,ddmmyyn2.));


%Macro MonthlyFile(date=&Today);
	%IF &date < 3 %THEN %DO;
		T
	%END;
	%IF &date < 7 %THEN %DO;
	%END;
	%IF &date < 9 %THEN %DO;
		A
	%END;
	%IF &date < 32 %THEN %DO;
		F
	%END;
%Mend;

%put NOTE: &reporting_period;
%put NOTE: %sysfunc(putn(&reporting_period,ddmmyy10.));
%put NOTE: &today;

%put NOTE:  %Repmth();
%put NOTE:  %monthlyfile();

%put NOTE:  %Repmth()%monthlyfile();

Hi guys,

Need help on my last part, why i cant write a result of 1223F?

 

I got an error says :Statement is not valid or it is used out of proper order.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Your first macro is emitting a semicolon.

If does not impact your first usages since running code like:

%put xxx;;

Just results in an extra empty statement.

But running code like:

%put 1233;F;

Is invalid.

 

PS If you want the day of the month just use the DAY() function.

%LET Today = %sysfunc(day(&Reporting_Period),z2.);

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Your first macro is emitting a semicolon.

If does not impact your first usages since running code like:

%put xxx;;

Just results in an extra empty statement.

But running code like:

%put 1233;F;

Is invalid.

 

PS If you want the day of the month just use the DAY() function.

%LET Today = %sysfunc(day(&Reporting_Period),z2.);
ChrisWoo
Obsidian | Level 7
Ahh, i got it now, all i want just a text and that semi colon is unnecessary.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 772 views
  • 0 likes
  • 2 in conversation