BookmarkSubscribeRSS Feed
desireatem
Pyrite | Level 9

data CP;

  input time A B;

cards;

1  .   .

2  0  .1

2  .4  .7

3   .3  .5

5   .9   0

6    .3  .33

;

I want to create a third and fourth variable calle Asum and Bsum

where  Asum= .+0+.4+.3+.9+.3

data CP;

  input time A B Asum  Bsum;

cards;

1  .   .    .+0+.4+.3+.9+.3     .+.1+.7+.5+0+.33

2  0  .1       0+.4+.3+.9+.3       1+.7+.5+0+.33

2  .4  .7        .4+.3+.9+.3         .7+.5+0+.33

3   .3  .5        .3+.9+.3              .5+0+.33

5   .9   0            .9+.3                0+.33

6    .3  .33              .3                  .33

;

1 REPLY 1
PGStats
Opal | Level 21

data CP;
input time A B;
cards;
1  .   .
2  0  .1
2  .4  .7
3   .3  .5
5   .9   0
6    .3  .33
;

data CPn;
set CP;
n = _n_;
run;

proc sort data=CPn; by descending n; run;

data want;
set CPn;
Asum + A;
Bsum + B;
run;

proc sort data=want out=want(drop=n); by n; run;

PG

PG

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 417 views
  • 2 likes
  • 2 in conversation