BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jjadall1
Quartz | Level 8

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
1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

8 REPLIES 8
ChrisNZ
Tourmaline | Level 20

Try

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

if these 2 variables are sas dates.

jjadall1
Quartz | Level 8

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.

ChrisNZ
Tourmaline | Level 20

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.

 

jjadall1
Quartz | Level 8

Here you go Chris - thanks a lot!

Jadallah

ChrisNZ
Tourmaline | Level 20

I download Microsoft files even less.

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

 

 

jjadall1
Quartz | Level 8

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

art297
Opal | Level 21

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

 

 

jjadall1
Quartz | Level 8

That worked Art!!!!!

 

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

 

God bless, best regards, and take care,

Jadallah

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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