BookmarkSubscribeRSS Feed
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

RamKumar
Fluorite | Level 6

thanks - Format is fine. But I need the output as I mentioned earlier.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

RamKumar
Fluorite | Level 6

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

output.png

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

RamKumar
Fluorite | Level 6

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Vix
Calcite | Level 5 Vix
Calcite | Level 5

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;

HBruun
Calcite | Level 5

*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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 23 replies
  • 4430 views
  • 0 likes
  • 5 in conversation