BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jopo12345678
Calcite | Level 5

Hello everyone,

I have this table

DATECOUNTCODEGRADESUM
20140144720014476
20140186910028713
20140182890038370
2014014011.
20140122012.
20140181013.
2014011164210111651
2014011936110219420
2014011528410315425
2014019111.
20140159112.
201401141113.

I want this

DATECOUNTCODEGRADESUMSUM2
20140144720014476.
20140186910028713.
20140182890038370.
2014014011.4476
20140122012.8713
20140181013.8370
2014011164210111651.
2014011936110219420.
2014011528410315425.
2014019111.11651
20140159112.19420
201401141113.15425

Basecally I want make another column SUM2 same as SUM but start in row 4.

Is there anybody who can solve my problem?

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1 reply
  • 709 views
  • 4 likes
  • 2 in conversation