BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User

you can try to  use another format.

format month6.  ;

Ksharp

carbs
Calcite | Level 5

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?

art297
Opal | Level 21

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.

Ksharp
Super User

Can you post some sample data and the output you want  be?

Ksharp

carbs
Calcite | Level 5

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..

Ksharp
Super User

Sorry. I have to leave now. Tomorrow I will take a look .

And I believe Art297 will give you something you want.

Ksharp

shivas
Pyrite | Level 9

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;

art297
Opal | Level 21

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;

carbs
Calcite | Level 5

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..

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 23 replies
  • 8729 views
  • 6 likes
  • 8 in conversation