Hello everyone,
I have this table
DATE | COUNT | CO | DE | GRADE | SUM |
201401 | 4472 | 0 | 0 | 1 | 4476 |
201401 | 8691 | 0 | 0 | 2 | 8713 |
201401 | 8289 | 0 | 0 | 3 | 8370 |
201401 | 4 | 0 | 1 | 1 | . |
201401 | 22 | 0 | 1 | 2 | . |
201401 | 81 | 0 | 1 | 3 | . |
201401 | 11642 | 1 | 0 | 1 | 11651 |
201401 | 19361 | 1 | 0 | 2 | 19420 |
201401 | 15284 | 1 | 0 | 3 | 15425 |
201401 | 9 | 1 | 1 | 1 | . |
201401 | 59 | 1 | 1 | 2 | . |
201401 | 141 | 1 | 1 | 3 | . |
I want this
DATE | COUNT | CO | DE | GRADE | SUM | SUM2 |
201401 | 4472 | 0 | 0 | 1 | 4476 | . |
201401 | 8691 | 0 | 0 | 2 | 8713 | . |
201401 | 8289 | 0 | 0 | 3 | 8370 | . |
201401 | 4 | 0 | 1 | 1 | . | 4476 |
201401 | 22 | 0 | 1 | 2 | . | 8713 |
201401 | 81 | 0 | 1 | 3 | . | 8370 |
201401 | 11642 | 1 | 0 | 1 | 11651 | . |
201401 | 19361 | 1 | 0 | 2 | 19420 | . |
201401 | 15284 | 1 | 0 | 3 | 15425 | . |
201401 | 9 | 1 | 1 | 1 | . | 11651 |
201401 | 59 | 1 | 1 | 2 | . | 19420 |
201401 | 141 | 1 | 1 | 3 | . | 15425 |
Basecally I want make another column SUM2 same as SUM but start in row 4.
Is there anybody who can solve my problem?
like this?
data have;
input DATE:yymmn6. COUNT CO DE GRADE SUM ;
format DATE yymmn6.;
datalines;
201401 4472 0 0 1 4476
201401 8691 0 0 2 8713
201401 8289 0 0 3 8370
201401 4 0 1 1 .
201401 22 0 1 2 .
201401 81 0 1 3 .
201401 11642 1 0 1 11651
201401 19361 1 0 2 19420
201401 15284 1 0 3 15425
201401 9 1 1 1 .
201401 59 1 1 2 .
201401 141 1 1 3 .
;
data want;
set have;
SUM2 = lag3(SUM);
run;
like this?
data have;
input DATE:yymmn6. COUNT CO DE GRADE SUM ;
format DATE yymmn6.;
datalines;
201401 4472 0 0 1 4476
201401 8691 0 0 2 8713
201401 8289 0 0 3 8370
201401 4 0 1 1 .
201401 22 0 1 2 .
201401 81 0 1 3 .
201401 11642 1 0 1 11651
201401 19361 1 0 2 19420
201401 15284 1 0 3 15425
201401 9 1 1 1 .
201401 59 1 1 2 .
201401 141 1 1 3 .
;
data want;
set have;
SUM2 = lag3(SUM);
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: