Current month vs Rolling month

  • Follow


Hi,

I am having the following variables as
pr_num,week,product,total_rxn,total_rx,sbu,terri_state and district.
I want to group the product by
terri_state ,total_rxn,total_rx,district for the current month &
previous month(here the date format is like this ddmmyyyy.
I need to develop a report for the current month & previous month.
Can anyone help me in this regard.

Regards,
Sid
0
Reply msiddu2000 (20) 12/25/2009 11:30:51 AM

Sid,

I think you will be more likely to get a response if you provide:

1. a sample dataset, in the form of a datastep
2. code that you tried to produce what you want would be nice
3. how you want the resulting report to look like, given the sample
data set

Art
----------
On Dec 25, 6:30 am, msiddu2000 <msiddu2...@gmail.com> wrote:
> Hi,
>
> I am having the following variables as
> pr_num,week,product,total_rxn,total_rx,sbu,terri_state and district.
> I want to group the product by
> terri_state ,total_rxn,total_rx,district for the current month &
> previous month(here the date format is like this ddmmyyyy.
> I need to develop a report for the current month & previous month.
> Can anyone help me in this regard.
>
> Regards,
> Sid
0
Reply art297 12/26/2009 4:39:54 PM


its a simple thing to get the current month with the month function. You
can form a where clause on a SAS date variable like

  where  month(datevar) = month(today());

The previous month might be a problem if you are in january. There are
several ways to get it. One is

  month(intnx("month",date,-1)) = month(intnx("month",today(),-1))

Gerhard





On Sat, 26 Dec 2009 08:39:54 -0800, Arthur Tabachneck
<art297@NETSCAPE.NET> wrote:

>Sid,
>
>I think you will be more likely to get a response if you provide:
>
>1. a sample dataset, in the form of a datastep
>2. code that you tried to produce what you want would be nice
>3. how you want the resulting report to look like, given the sample
>data set
>
>Art
>----------
>On Dec 25, 6:30 am, msiddu2000 <msiddu2...@gmail.com> wrote:
>> Hi,
>>
>> I am having the following variables as
>> pr_num,week,product,total_rxn,total_rx,sbu,terri_state and district.
>> I want to group the product by
>> terri_state ,total_rxn,total_rx,district for the current month &
>> previous month(here the date format is like this ddmmyyyy.
>> I need to develop a report for the current month & previous month.
>> Can anyone help me in this regard.
>>
>> Regards,
>> Sid
0
Reply gerhard.hellriegel (2531) 12/26/2009 8:50:01 PM

hi,

for the next example dataset:

data test;
input total_sales country $ date;
format date ddmmyy10.;
cards;
10000  FR 18180
12300  UK 18213
2700   UK 18229
11000  SP 18255
5000   PT 18259
;
run;

you can filter the last 2 months with the next macro ( and forget to
rewrite the filter for next monthly periods):


%macro bimonthly;
%global begin end output;
%let begin=%sysfunc(intnx(month, "&SYSDATE9."d, -1));
%let end=%eval(%sysfunc(intnx(month, "&SYSDATE9."d, 1))-1);
%let output=%sysfunc(catx(_,%sysfunc(putn(&begin,MONYY5.)),%sysfunc(putn(&end,MONYY5.))));
%mend;
%bimonthly;

proc summary data=test (where=(&begin <= date <=&end)) nway;
class country;
var total_sales;
output out=&output (drop=_:) sum()=;
run;

Daniel Fernandez
Barcelona.



2009/12/26 Arthur Tabachneck <art297@netscape.net>:
> Sid,
>
> I think you will be more likely to get a response if you provide:
>
> 1. a sample dataset, in the form of a datastep
> 2. code that you tried to produce what you want would be nice
> 3. how you want the resulting report to look like, given the sample
> data set
>
> Art
> ----------
> On Dec 25, 6:30 am, msiddu2000 <msiddu2...@gmail.com> wrote:
>> Hi,
>>
>> I am having the following variables as
>> pr_num,week,product,total_rxn,total_rx,sbu,terri_state and district.
>> I want to group the product by
>> terri_state ,total_rxn,total_rx,district for the current month &
>> previous month(here the date format is like this ddmmyyyy.
>> I need to develop a report for the current month & previous month.
>> Can anyone help me in this regard.
>>
>> Regards,
>> Sid
>
0
Reply fdezdan (222) 12/31/2009 10:59:28 AM

3 Replies
241 Views

(page loaded in 0.064 seconds)

Similiar Articles:













7/16/2012 7:38:28 PM


Reply: