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

Hi,

 

I'm trying to find the Week Begin Date from a Given Date with Saturday as the Starting point. I've tried the following code but it always yields a Sunday Start Date. I would like x=24Oct2019 to return  10/20/19  (Saturday) & 26Oct2019 to return 10/26/19 (Also Saturday).

data _null_;

x='24Oct2019'd;

e=intnx("week",x,0,"B")

put e=;

format e mmddyy10;

run;

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
e=intnx("week.7",x,0,"B")
--
Paige Miller

View solution in original post

6 REPLIES 6
PGStats
Opal | Level 21
data _null_;
do x='20Oct2019'd to '30Oct2019'd;
	e=intnx("week.7",x,0,"B");
	put (x e) (+1 yymmdd10.);
	end;
run;
  2019-10-20 2019-10-19
  2019-10-21 2019-10-19
  2019-10-22 2019-10-19
  2019-10-23 2019-10-19
  2019-10-24 2019-10-19
  2019-10-25 2019-10-19
  2019-10-26 2019-10-26
  2019-10-27 2019-10-26
  2019-10-28 2019-10-26
  2019-10-29 2019-10-26
  2019-10-30 2019-10-26
PG
RADAGBE9
Fluorite | Level 6

Thanks. Worked Perfectly.

jpprovost
Quartz | Level 8

@PGStats wrote:
data _null_;
do x='20Oct2019'd to '30Oct2019'd;
	e=intnx("week.7",x,0,"B");
	put (x e) (+1 yymmdd10.);
	end;
run;
  2019-10-20 2019-10-19
  2019-10-21 2019-10-19
  2019-10-22 2019-10-19
  2019-10-23 2019-10-19
  2019-10-24 2019-10-19
  2019-10-25 2019-10-19
  2019-10-26 2019-10-26
  2019-10-27 2019-10-26
  2019-10-28 2019-10-26
  2019-10-29 2019-10-26
  2019-10-30 2019-10-26

Hi @PGStats ,

Just a curiosity question. What does this line do?

	put (x e) (+1 yymmdd10.);

I know that put will conver num to char, but I don't understand the "+1"? 

PGStats
Opal | Level 21

The +1 adds a space character. Try removing it! Smiley Wink

PG
jpprovost
Quartz | Level 8

@PGStats wrote:

The +1 adds a space character. Try removing it! Smiley Wink


I'll for sure. There's so many "behind the scene" tricks with SAS that I don't know. I didn't know that you can use put (var1 var2) (format) in that way.

Thanks for your help.

PaigeMiller
Diamond | Level 26
e=intnx("week.7",x,0,"B")
--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 1088 views
  • 2 likes
  • 4 in conversation