Folks, thanks again for your assistance. I think I am getting there.
here is my code so far
------------------CODE------------------------------
data _null_; format week comma10.0; format date1 date2 date_today date9.; format date MONYY.;
if 8 <= day(today()) <= 14 then do; week = 1 ; date = intnx('month',today(),0); date1 = intnx('month',today(),0, 'b'); date2 = intnx('month',today(),1, 'b'); date_today = intnx('week',today(),0); end; else if 15 <= day(today()) <= 21 then do; week = 2 ; date = intnx('month',today(),0); date1 = intnx('month',today(),0, 'b'); date2 = intnx('month',today(),1, 'b'); date_today = intnx('week',today(),0); end; else if 22 <= day(today()) <= 31 then do; week = 3 ; date = intnx('month',today(),0); date1 = intnx('month',today(),0, 'b'); date2 = intnx('month',today(),1, 'b'); date_today = intnx('week',today(),0); end; else if 1 <= day(today()) <= 7 then do; week = 4 ; date = intnx('month',today(),-1); date1 = intnx('month',today(),-1, 'b'); date2 = intnx('month',today(),0, 'b'); date_today = intnx('week',today(),0); end;
put date1 date2 date_today DATE9.; put date MONYY.;
call symputx('week',week); call symputx('date',date); call symputx('date1',date1); call symputx('date2',date2); call symputx('date_today',date_today);
run;
%put date = &date. date1 = &date1. date2 = &date2. date_today = &date_today. week = &week.;
--------------------------Log file -----------------------------------------------
5676 else if 5677 1 <= day(today()) <= 7 then 5678 do; 5679 week = 4 ; 5680 date = intnx('month',today(),-1); 5681 date1 = intnx('month',today(),-1, 'b'); 5682 date2 = intnx('month',today(),0, 'b'); 5683 date_today = intnx('week',today(),0); 5684 end; 5685 5686 put date1 date2 date_today DATE9.; 5687 put date MONYY.; 5688 5689 5690 call symputx('week',week); 5691 call symputx('date',date); 5692 call symputx('date1',date1); 5693 call symputx('date2',date2); 5694 call symputx('date_today',date_today); 5695 5696 run;
01MAY2017 01JUN2017 21MAY2017 MAY17 NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
SYMBOLGEN: Macro variable DATE resolves to 20940 5697 SYMBOLGEN: Macro variable DATE1 resolves to 20940 5698 SYMBOLGEN: Macro variable DATE2 resolves to 20971 5699 SYMBOLGEN: Macro variable DATE_TODAY resolves to 20960 5700 SYMBOLGEN: Macro variable WEEK resolves to 3 5701 %put date = &date. date1 = &date1. date2 = &date2. date_today = &date_today. week = &week.; date = 20940 date1 = 20940 date2 = 20971 date_today = 20960 week = 3
----------------------------------------------------Remaining Issue ---------------------------------------
my date_today is not set up properly
I want date today to be as follows
if today is between 8th day of the month to 14th day of the month: 8th day of the month, as en example 8May2017
if today is between 15th day of the month to 21nd day of the month: 15th day of the month, as en example 15May2017
if today is between 22nd day of the month to 31st day of the month: 22nd day of the month, as en example 22May2017
...
I tried differnet logic as posted above but nothing is work so far, please advise
Thanks again
... View more