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 2025: Call for Content

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!

Submit your idea!

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.

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