you can try to use another format.
format month6. ;
Ksharp
This solved part of the problem using ballardw's formula. However it just calculates all of countries quarterly/sixmonth returns together, how can I adjust it to get results per country?
I don't recall you having mentioned Country before. If it is a field you have, just add it at the beginning of the Class statement.
Can you post some sample data and the output you want be?
Ksharp
I've attached to the first post two files, forum and forum1. First of them is the format I have the data now. Forum1 is the outcome using Vx=Xc's code, which was just how I wanted the results to be... However I need two different sets also, where there is 6month data instead of quarter, and also the case where there is only yearly data for each country. Couldn't do this with that code, maybe easier using ballardw's code..
Sorry. I have to leave now. Tomorrow I will take a look .
And I believe Art297 will give you something you want.
Ksharp
Hi,
If you have ETS software ,you can use this procedure for quaterly aswell as well as for 6 months...
Try this..
proc expand data=have out=want from=month to=semiannual;
convert SMB_Dom HML_Dom MOM_Dom ;
by country;
id dat1;
run;
proc expand data=have out=want from=month to=qtr;
convert SMB_Dom HML_Dom MOM_Dom ;
by country;
id dat1;
run;
I would use something like the following. It uses an extra datastep, but I think it will be easier to following what the code does:
data have;
set have;
year=year(dat1);
quarter=qtr(dat1);
if quarter in (1,2) then semi_annual=1;
else semi_annual=2;
run;
proc summary data=have nway;
class country year quarter;
var SMB_Dom--lagthreembill_char;
output out= final1 (drop= _type_ _freq_) sum= ;
run;
proc summary data=have nway;
class country year semi_annual;
var SMB_Dom--lagthreembill_char;
output out= final2 (drop= _type_ _freq_) sum= ;
run;
Thanks art, again exactly what I wanted! Chivas's code didn't do the job, it only counts every x other observation, not summing them up..
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.