Like this?
data HAVE;
input ID RELEASE_DATE mmddyy8. DATENUM ;
cards;
1 03/02/11 1245
2 01/01/11 3423
2 01/10/11 5432
run;
data WANT;
set HAVE;
by ID ;
array MONTH[24] $32;
retain MONTH1-MONTH24;
INDEX=intck('month','01dec2010'd,RELEASE_DATE);
MONTH[INDEX]=catt(MONTH[INDEX],DATENUM);
if last.ID then do;
output;
call missing(of MONTH{*]);
end;
run;
proc print noobs;
var ID MONTH1-MONTH3;
run;
SAS Output
| ID | MONTH1 | MONTH2 | MONTH3 |
|---|---|---|---|
| 1 | 1245 | ||
| 2 | 34235432 |
Like this?
data HAVE;
input ID RELEASE_DATE mmddyy8. DATENUM ;
cards;
1 03/02/11 1245
2 01/01/11 3423
2 01/10/11 5432
run;
data WANT;
set HAVE;
by ID ;
array MONTH[24] $32;
retain MONTH1-MONTH24;
INDEX=intck('month','01dec2010'd,RELEASE_DATE);
MONTH[INDEX]=catt(MONTH[INDEX],DATENUM);
if last.ID then do;
output;
call missing(of MONTH{*]);
end;
run;
proc print noobs;
var ID MONTH1-MONTH3;
run;
SAS Output
| ID | MONTH1 | MONTH2 | MONTH3 |
|---|---|---|---|
| 1 | 1245 | ||
| 2 | 34235432 |
thank you! that worked perfectly!!
If you need it for a report use proc tabulate.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.