BookmarkSubscribeRSS Feed
srikanthyadav44
Quartz | Level 8

Dear all,

Greetings of the day

 

I have  the quarterly data of a variable from june,2009 to march, 2018.  

with those values, i have to compute the average value of the variable for the previous three years. 

 

For example, at the end of march, 2012, i have to compute the average value of the variable from june,2009 to march,2012.

Next at the end of march, 2013, i have to compute the average value of the variable from june,2010 to march,2013. and so on  till march, 2018. 

 

the format of my dataset is as follows

Company Namevar_june2009var_sept2009var_dec2009var_march2010................var_march2018
20 Microns Ltd.2.052.050.460.29..............0.29
3I Infotech Ltd.4.417.7416.598.08...............8.22
3M India Ltd.5.925.885.425.33...............5.14

 

please help me writing the SAS code to perform the above mentioned calculation. 

 

thanks in advance. 

1 REPLY 1
Reeza
Super User
You likely want an array but the coding should be pretty straightforward with an array. Have you tried an array solution yet? It would help if you can provide some data as a data step.

https://stats.idre.ucla.edu/sas/seminars/sas-arrays/arrays-in-sas/

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 705 views
  • 0 likes
  • 2 in conversation