Counting Periods

Accepted Solution Solved
Reply
Contributor
Posts: 65
Accepted Solution

Counting Periods

Hello SAS Support Communities,

I have a few variables left to calculate for this portion of my dissertation.  One of them is calculating the number of quarters covered between rpb and rpe.  The periods1 dataset is the starting point.  The fyr variable is the month of the end of a fiscal year.  For instance, observation 1 has an fyr of 12.  That means 12/31 is the end of the fiscal year.  
 
In the periods1b dataset, fyr1a is the beginning of the fiscal year.  In observation 1, fyr1a is 1 which means that 1/1 is the beginning of the fiscal year.
 
Periods2 is the way the dataset should look.  Each quarter counts as 0.25.  Observation 1 covers 3 years (4 quarters per year for 3 years).  Therefore, the periods variable = 3;
 
Look at observation 2.  Fyr is 7, meaning 7/31 is the end of the fiscal year.  Since restatement period is from 7/1/2013 through 7/31/2014, parts of 5 quarters are covered (7/1/2013 through 7/31/2013, 8/1/2013 through 10/31/2013, 11/1/2013 through 1/31/2013, 2/1/2014 through 4/30/2014, and 5/1/2014 through 7/31/2014).  Therefore, the periods variable = 1.25 (0.25 X 5).  
 
I tried using the intck function as follows:
data dissert1.periods1c;
set dissert1.periods1b;
quarters=intck(qtr,rpb,rpe,'C');
run;
 
I received the following error in the log:
3052  quarters=intck('qtr','rpb''d,'rpe'd);
                                    ---
                                    76
ERROR 76-322: Syntax error, statement will be ignored.
 
3066  data dissert1.periods1c;
3067  set dissert1.periods1b;
3068  quarters=intck(qtr,rpb,rpe,'C');
3069  run;
 
How should I resolve this?
 
Thank you so much in advance for your help!
 
God bless, best regards, and take care,
Jadallah
Attachment
Attachment
Attachment

Accepted Solutions
Solution
‎03-13-2018 08:14 PM
PROC Star
Posts: 7,988

Re: Counting Periods

I think that the following does what you want. It only uses the periods1a dataset:

data periods1a;
  infile cards dlm=',' dsd;
  input CIK fyr rpb : mmddyy10. rpe : mmddyy10.;
  format rpb rpe mmddyy10.;
  cards;
1234367,12,1/1/2007,12/31/2009
1576888,7,7/1/2013,7/31/2014
2008765,5,3/1/2012,6/15/2013
6875330,12,1/1/2013,1/31/2014
9877364,9,10/1/2011,9/30/2012
;

data want;
  set periods1a;
  Periods=(intck(catt('qtr.',mod(fyr,3)+1),rpb,rpe)+1)/4;
run;

Art, CEO, AnalystFinder.com

 

 

View solution in original post


All Replies
PROC Star
Posts: 2,128

Re: Counting Periods

Try

quarters=intck('qtr',rpb,rpe);

if these 2 variables are sas dates.

Contributor
Posts: 65

Re: Counting Periods

Thank you Chris.  I received output, which is progress.  However, the fyr issue was not taken into consideration and, therefore, some of the results are wrong.

PROC Star
Posts: 2,128

Re: Counting Periods

Please post a few lines of:

- existing data

- wanted data

I am not downloading zip files.

The lines don't have to be complete data, just a sample to illustrate  the calculations you need.

 

Contributor
Posts: 65

Re: Counting Periods

Here you go Chris - thanks a lot!

Jadallah

PROC Star
Posts: 2,128

Re: Counting Periods

I download Microsoft files even less.

Please post data as data steps (and check that they run fine).

 

 

Contributor
Posts: 65

Re: Counting Periods

Periods1a Dataset:

CIK fyr rpb rpe
1234367 12 1/1/2007 12/31/2009
1576888 7 6/30/2013 7/31/2014
2008765 5 3/1/2012 6/15/2013
6875330 12 1/1/2013 1/31/2014
9877364 9 10/1/2011 9/30/2012

 

Fyr is the end of a fiscal year.

 

Periods1b Dataset:

CIK fyr rpb rpe fyr1 fyr1a
1234367 12 1/1/2007 12/31/2009 13 1
1576888 7 6/30/2013 7/31/2014 8 8
2008765 5 3/1/2012 6/15/2013 6 6
6875330 12 1/1/2013 1/31/2014 13 1
9877364 9 10/1/2011 9/30/2012 10 10

 

Fyr1a is the beginning of a fiscal year.

 

Periods2 Dataset (what I want):

CIK fyr rpb rpe Periods
1234367 12 1/1/2007 12/31/2009 3
1576888 7 7/1/2013 7/31/2014 1.25
2008765 5 3/1/2012 6/15/2013 1.5
6875330 12 1/1/2013 1/31/2014 1.25
9877364 9 10/1/2011 9/30/2012 1

With observation 1, there are 3 years that are covered.


With observation 2, 7/1/2013 is in the quarter that ends 7/31/2013.  That is 0.25 and 1 year (8/1/2013 through 7/31/2014) to get 1.25.

 

God bless, best regards, and thanks again Chris!

Jadallah

Solution
‎03-13-2018 08:14 PM
PROC Star
Posts: 7,988

Re: Counting Periods

I think that the following does what you want. It only uses the periods1a dataset:

data periods1a;
  infile cards dlm=',' dsd;
  input CIK fyr rpb : mmddyy10. rpe : mmddyy10.;
  format rpb rpe mmddyy10.;
  cards;
1234367,12,1/1/2007,12/31/2009
1576888,7,7/1/2013,7/31/2014
2008765,5,3/1/2012,6/15/2013
6875330,12,1/1/2013,1/31/2014
9877364,9,10/1/2011,9/30/2012
;

data want;
  set periods1a;
  Periods=(intck(catt('qtr.',mod(fyr,3)+1),rpb,rpe)+1)/4;
run;

Art, CEO, AnalystFinder.com

 

 

Contributor
Posts: 65

Re: Counting Periods

That worked Art!!!!!

 

Thank you so much for your help - awesome job!!!

 

God bless, best regards, and take care,

Jadallah

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 128 views
  • 0 likes
  • 3 in conversation