BookmarkSubscribeRSS Feed
Swapnasis
Calcite | Level 5

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)


sas q1.jpg
6 REPLIES 6
ballardw
Super User

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?

Swapnasis
Calcite | Level 5
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

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Reeza
Super User

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. 

Swapnasis
Calcite | Level 5

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

Reeza
Super User

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;
Swapnasis
Calcite | Level 5

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

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 1316 views
  • 0 likes
  • 3 in conversation