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.

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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