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)
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?
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.
Below is the attachment of the input data.U have write a code to produce a dataset which looks llike my previous image
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;
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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.