## Quarters and Periods

Occasional Contributor
Posts: 5

# Quarters and Periods

For this dataset only variable A is populated ,I want to create 2 variables date and periods as shown in the excel.The code should be such that once i specify the start date and end date,it should generate all the quarters and their corresponding period starting from zero.In this dataset variable A has 42 values,so if i specify start date as 31-dec-2015 and end date as 31-dec-2020,it should generate all the inbetween quarters as shown in image and also their corresponding quartes.it should also repeat iti.e if Variable A has 42 values it should repeat it twice(42/21)

Super User
Posts: 13,508

## Re: Quarters and Periods

Do you have the possiblity where a value for the A variable might duplicate a previous value but not be the start of a duplicate set?

What is the largest number of values that might be involved with a sequence in A?

Occasional Contributor
Posts: 5

## Re: Quarters and Periods

the Variable A can carry any value(not specific to what I have shown in
the image).but the total no.of rows will be in mutiples of 21.
What I exactly want is if the variable A is given in the input
dataset.create the two varibles dates and period as given in the image file

attachments. -##
Super User
Posts: 23,683

## Re: Quarters and Periods

Well, without sample input data (I'm not going to type out your data from a picture) I think the code provided initially is a good start.

If you've tried it, please post what you've tried and what doesn't work.

Occasional Contributor
Posts: 5

## Re: Quarters and Periods

Below is the attachment of the input data.U have write a code to produce a dataset which looks llike my previous image

Super User
Posts: 23,683

## Re: Quarters and Periods

How are you providing your start/end date. That looks like output, what does your input look like.

What you should be doing is sketched out below - untested.

1. Finding the number of periods you need to create by using your start/end date with the INTCK function

``````num_quarters = intck('QTR', start_date, end_date);
``````

2. Loop over the number of quarters and increment date

``````do i= 1 to num_quarters;
date = intnx('Quarter', start_date, i, 'b');
OUTPUT;
end;``````
Occasional Contributor
Posts: 5

## Re: Quarters and Periods

To me only the dataset with variable A is populated.I have been told that start date is 31-Dec-2015 and end date is 31-dec2020.

I have to create a dates coloumn such that all the 21 quarters are populated in a manner as shown in the image file.along with that i have to create a period coloumn as  shown in the image

Discussion stats
• 6 replies
• 447 views
• 0 likes
• 3 in conversation