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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 1205 views
  • 5 likes
  • 5 in conversation