BookmarkSubscribeRSS Feed
Reeza
Super User

From what you've shown here, arrays won't help. 

Shmuel
Garnet | Level 18

I see that some companies have only one year data while other may have more.

I understand that for each company-year you want the all 4 periods.

I suggest you try next code:

proc sql;
    create table companies as
    select distint company, yymm_e
    from have;
quit;

data skeleton;
   set companies;
         year = year(yymm_e) -1;  /* assuming yymm_e is a sas date variable */  
/* if it is a six digits number then year = int(yymm_e / 100) -1; */ array qtr 03 06 09 12; do i=1 to 4; yymm = mdy(qtr,1,year); output; end; format yymm yymmn6. ; keep company yymm; run; data want; merge skeleton have; by company yymm; run;

Look at each of the tables that were created at the process.

If the want table is not the desired result - please post the result of one company and show what's wrong with it and what should be.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 17 replies
  • 3341 views
  • 5 likes
  • 5 in conversation