BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ldavis020
Fluorite | Level 6

Hello! I'm attempting to create a new variable that assigns the mean in period 2 to period 1 for each group. Better to explain with the data. 

 

This is what I have: 

data have;
input group period mean;
datalines;
1 1 10
1 2 20
2 1 33
2 2 22
3 1 21
3 2 34
4 1 33
4 2 32
;
run;

This is what I want:

data want;
input group period mean meanp2;
datalines;
1 1 10 20 
1 2 20 20
2 1 33 22
2 2 22 22
3 1 21 34
3 2 34 34
4 1 33 32
4 2 32 32
;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ldavis020
Fluorite | Level 6

Answered my own question. Sorry thanks!! 

 

For references the solution is: 

 

data p2; set have;
meanp2=mean;
where period=2;
run;

data want; 
merge p2 have;
by group;
run;

 

View solution in original post

1 REPLY 1
ldavis020
Fluorite | Level 6

Answered my own question. Sorry thanks!! 

 

For references the solution is: 

 

data p2; set have;
meanp2=mean;
where period=2;
run;

data want; 
merge p2 have;
by group;
run;

 

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
  • 1 reply
  • 266 views
  • 0 likes
  • 1 in conversation