BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sivastat08
Pyrite | Level 9


Hi ,

 

I am trying to create monday and friday using sysfunc in sas EG but its not working for me.Kindly help me on below code.

 

%LET Monday = %SYSFUNC(INTNX('WEEK.2',%SYSFUNC(TODAY()),2),DOWNAME.);
%PUT &Monday;
%LET Friday = %SYSFUNC(INTNX('WEEK.6',%SYSFUNC(TODAY()),6),DOWNAME.);
%PUT &Friday;


Thanks,

Siva

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Small changes

 

%LET Monday = %SYSFUNC(INTNX(WEEK.2,%SYSFUNC(TODAY()),0), 'b');
%PUT &Monday;
%LET Friday = %SYSFUNC(INTNX(WEEK.6,%SYSFUNC(TODAY()),0), 'b');
%PUT &Friday;

View solution in original post

10 REPLIES 10
PeterClemmensen
Tourmaline | Level 20

Small changes

 

%LET Monday = %SYSFUNC(INTNX(WEEK.2,%SYSFUNC(TODAY()),0), 'b');
%PUT &Monday;
%LET Friday = %SYSFUNC(INTNX(WEEK.6,%SYSFUNC(TODAY()),0), 'b');
%PUT &Friday;
sivastat08
Pyrite | Level 9
Hello Sir, Thanks for the answer, Code ae working fine but Format is not showing Monday or Friday
26 GOPTIONS ACCESSIBLE;
27 %LET Monday = %SYSFUNC(INTNX(WEEK.2,%SYSFUNC(TODAY()),0), 'b');
28 %PUT &Monday;
21738
29 %LET Friday = %SYSFUNC(INTNX(WEEK.6,%SYSFUNC(TODAY()),0), 'b');
30 %PUT &Friday;
21742

,Kindly help me on format
PeterClemmensen
Tourmaline | Level 20

What is the Purpose of this? Are you going to use the actual date variables or do you simply want to print 'Monday' and 'Friday' in the log?

sivastat08
Pyrite | Level 9

I want to send automated email using email body mentioning monday date and friday date as "08Mon19 - 16Fri19"

PeterClemmensen
Tourmaline | Level 20

So the real task is to get the string "08Mon19 - 16Mon19" into a macro variable?

sivastat08
Pyrite | Level 9

Yes sir.This code will run on every friday it should display Current Week Monday to Friday date Dynamically. 

sivastat08
Pyrite | Level 9

here is the sample code

%LET TODAY=%SYSFUNC(TODAY(),DATE9.);
%PUT &TODAY;

 

%LET Monday = %SYSFUNC(INTNX(WEEK.2,%SYSFUNC(TODAY()),0), 'b');
%PUT &Monday DOWNAME.;
%LET Friday = %SYSFUNC(INTNX(WEEK.6,%SYSFUNC(TODAY()),0), 'b');
%PUT &Friday;


filename outbox email
to= ('XXX.YYY@abchealth.com')
cc= ('sivakumar.siva@abchealth.com')
type='text/html'
subject="Weekly Status";
data _null_;
file outbox;
put "Hi all";
put "<P>";
Put "Please find the Weekly Status Report of 08July2019 - 12jul2019 ";
put "<P>";
put "Thank you,";
run;

 

Tom
Super User Tom
Super User

No need for messing with macro variables if you are already running a data step.

data _null_;
  file outbox;
  monday=intnx('week.2',today(),0);
  friday=monday+4;
  put 'Hi all';
  put '<P>';
  put 'Please find the Weekly Status Report of ' monday date9. ' - ' friday date9.;
  put '<P>';
  put 'Thank you,';
run;
Tom
Super User Tom
Super User

@sivastat08 wrote:

I want to send automated email using email body mentioning monday date and friday date as "08Mon19 - 16Fri19"


Then why are you making it harder by trying to do it in macro code? Just do it in a data step and eliminate a lot of complexity.

sivastat08
Pyrite | Level 9

Sure Tom.Thank you for such a detailed answer!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 10 replies
  • 2763 views
  • 5 likes
  • 3 in conversation