Desktop productivity for business analysts and programmers

Creating by-weekly expenses in EG

Reply
Contributor
Posts: 36

Creating by-weekly expenses in EG

Hi there

I would like to know how to group daily expenses into a by-weekly format. Since i've worked with a small database i've used the recoded function and applied ranges.

Date of ChargeBy-Weekly Expenses
16FEB201229FEB2012
01MAR201215MAR2012
19FEB201328FEB2012
04APR201315APR2013

i'll appreciate the help to construct a condition to apply in the Advanced Expression option

Thanks

César

Super User
Posts: 19,167

Re: Creating by-weekly expenses in EG

I think we need some more detail as to what you're looking to do.

One thing to look into is formats for the date variable that will automatically calculate a week portion of the date and then if you can use that to help with your calculation.

If you're looking for bi-weekly dates you could subtract or add 1 week to the result if you had an odd number for example.

Contributor
Posts: 36

Re: Creating by-weekly expenses in EG


I basically want to fit a historical range of purchases dates into a by-weekly format. For every purchase between 01AUG2012 and 15AUG2012, label them as 15AUG2012 and the same for some other purchase between 16AUG2012 and 31AUG2012 with the label 31AUG2012.

Since i have too much data, i cannot keep creating a format within the recoded function.

Super User
Posts: 19,167

Re: Creating by-weekly expenses in EG

Are your bi-weekly dates custom?

I'm recommending using SAS pre-built formats so that you don't need to rebuild anything.

Contributor
Posts: 36

Re: Creating by-weekly expenses in EG

Since i'm not that skillful yet with some unknown functions, i was given this (example) to arrange dates in a different bi-weekly format:

ifn(day(t1.purchase_date)<=15, intnx('month',t1.purchase_date,0,'e'), intnx('month',t1.purchase_date,1,'m'))

I'm trying to understand the conditions from this formula to fit my neccesities in a customized format.

Super User
Posts: 19,167

Re: Creating by-weekly expenses in EG

That seems to only divide it into two time periods for a month, not biweekly.

Super User
Posts: 19,167

Re: Creating by-weekly expenses in EG

My bi_week2 gives you biweekly counts and you can add/subtract 7 to get it closer to what you need and seems simpler.

You can refer to the docs for the definition of the intnx function, but basically it increments dates within specified intervals, in this case a biweek interval, WEEK2.

data have;

    do date="01Mar2013"d to "01Jun2013"d;

        bi_week=ifn(day(date)>=15, intnx('month',date,0,'e'), intnx('month',date,1,'m'));

        bi_week2=intnx('WEEK2', date, 0, 'BEGINNING');

        output;

    end;

    format date bi_week bi_week2 date9.;

run;

Contributor
Posts: 36

Re: Creating by-weekly expenses in EG

Thanks i'll give it a try and let you know.

I appreciate the help

Ask a Question
Discussion stats
  • 7 replies
  • 277 views
  • 0 likes
  • 2 in conversation