Errrm, then just add format into mine?
data want (drop=j);
format start_date end_date date9.;
do name="Raj","Ravi","Ram";
do j=0 to 3;
start_date=intnx('week','06FEB2014'd,j);
end_date=intnx('week','06JUN2014'd,j);
output;
end;
end;
run;
thanks - Format is fine. But I need the output as I mentioned earlier.
Ah, I see. Its three day gaps or something similar. Check out the SAS docs: SAS(R) 9.3 Functions and CALL Routines: Reference
You can use DAY3 or whatever your interval is, and change the J loop to be how many times you want it:
data want (drop=j);
format start_date end_date date9.;
do name="Raj","Ravi","Ram";
do j=0 to 3;
start_date=intnx('day3','06FEB2014'd,j);
end_date=intnx('day3','06JUN2014'd,j);
output;
end;
end;
run;
I think you've misunderstood my question. I agree with you, but I looking for end date is startdate+4 days and not 06jun2014.
i need the output as below
data want (drop=j);
format start_date end_date date9.;
do name="Raj","Ravi","Ram";
do j=0 to 3;
start_date=intnx('day3','06FEB2014'd,j);
end_date=intnx('day3',start_date,j); /* Think you can change this to day4 if that's whats needed */
output;
end;
end;
run;
Thanks for your suport and patience. But still it is now working as i expect.
See the output below for your code after I changed day 3 to day4 in end_date variable
obs start_date end_date name
1 04FEB2014 02FEB2014 Raj
2 07FEB2014 10FEB2014 Raj
3 10FEB2014 18FEB2014 Raj
4 13FEB2014 22FEB2014 Raj
5 04FEB2014 02FEB2014 Rav
6 07FEB2014 10FEB2014 Rav
7 10FEB2014 18FEB2014 Rav
8 13FEB2014 22FEB2014 Rav
9 04FEB2014 02FEB2014 Ram
10 07FEB2014 10FEB2014 Ram
11 10FEB2014 18FEB2014 Ram
12 13FEB2014 22FEB2014 Ram
Yes, just change the j in the second intnx to be one as this part is linked to start_date not to the do loop:
data want (drop=j);
format start_date end_date date9.;
do name="Raj","Ravi","Ram";
do j=0 to 3;
start_date=intnx('day4','06FEB2014'd,j);
end_date=intnx('day4',start_date,1); /* Think you can change this to day4 if that's whats needed */
output;
end;
end;
run;
So start date will be 4 day intervals 3 times based on the loop, end_date is 4 days after start_date.
data want (drop=j); CALL SYMPUTX('DATE1', '01JAN2014'D); do name= "RAJ", "RAVI", "RAM"; DO J=0 TO 52; START_DATE= PUT(INTNX('WEEK',SYMGET('DATE1'),J,'B') +1, DATE9.); END_DATE = PUT(INTNX('WEEK',SYMGET('DATE1'),J,'E')-1, DATE9.); OUTPUT; END; END; RUN;
*Make a dateset with your agents;
data agents;
input name $;
datalines;
Raj
Ravi
Ram
;
run;
data schedule;
set agents;
*start date as monday;
start=intnx('week', today(), 0)+1; * +1 to get monday. Change 0 to +1 for next week ;
do start_date = start to '31dec2014'd by 6;
end_date=start_date +4;
output;
end;
format start_date end_date ddmmyy10.;
drop start;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.