BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bhr-q
Pyrite | Level 9

Hello all,

many thanks to help me to convert the first design to the second design?

 

Id             B       w     g

 1               10     .        .

 1                .        8     .

 1               .        .        6

2              12      .           .

2               .      15        .

2               .        .         17

.

.

.

 

second design:

Id              B        w          g

1               10       8          6

2              12      15         17

3

.

.

.

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Assuming you want the last non-missing value for each variable in the group just use the UPDATE statement.  That requires two datasets, the original data and the transactions to be applied.  But you can use your existing dataset in both places.  Just start with zero observations.

data want;
  update have(obs=0) have;
  by id;
run;

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

Assuming you want the last non-missing value for each variable in the group just use the UPDATE statement.  That requires two datasets, the original data and the transactions to be applied.  But you can use your existing dataset in both places.  Just start with zero observations.

data want;
  update have(obs=0) have;
  by id;
run;
bhr-q
Pyrite | Level 9

Thanks so much, that's an easy way. 

PaigeMiller
Diamond | Level 26
proc summary data=have nway;
    class id;
    var b w g;
    output out=want sum=;
run;
--
Paige Miller
bhr-q
Pyrite | Level 9
Another easy way. Thanks so much for sharing your info.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 449 views
  • 3 likes
  • 3 in conversation