Smart questions
Smart people
 Find A ForumFind An Expert
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Remember Me

Are you a
Computer / IT professional?
Join Tek-Tips now!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Just copy and paste the

#### Feedback

"...This is easily the most helpful website I've ever used, and this is the best forum with the quickest response time bar none...."

#### Geography

Where in the world do Tek-Tips members come from?

# HOW TO RETAIN A VALUE IN A GROUP WHEN A CONDITION IS TRUE

 Forum Search FAQs Links Jobs Whitepapers MVPs
 kushiwije (TechnicalUser) 30 Apr 12 9:59
 Hi I have this data set as below. X  Y -  - 1  A 1  A 1  A 1  D 1  J  2  B 2  B 2  D 2  C 2  CWithin a given value of X, when Y=D, I would like to reset the remaining values for Y to D. So the data set should look like this. X  Y -  - 1  A 1  A 1  A 1  D 1  D  2  B 2  B 2  D 2  D 2  DAny help is greatly appreciated. Thanks!
 sasbuddy (Programmer) 2 May 12 2:09
 Refer the following program, for desired output.data t;input X  Y \$;cards; 1  A 1  A 1  A 1  D 1  J  2  B 2  B 2  D 2  C 2  C 3  A 3  D 4  A 4  B 4  D 4  C 4  D 4  R 4  R;run;proc sort data =t;by X;run;data t (drop=flag);set t;retain flag 0;by x;if first.x then flag = 0;if y = 'D' then flag = 1;if flag = 1 then y = 'D';run;

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!