BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Deb4
Fluorite | Level 6
How do I change the values of age and salary both for Matt?
Can it be done using if statement?
data people;
input name $ age salary;
datalines;
Timothy 25 1200
Mark 30 1500
Matt 29 1600
;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

How many of these records need to be updated? Is the Name duplicated?

 

If you only have a few of these then perhaps an "if" is appropriate: an example with made up values since you did not provide any.

The key with multiple variables is to place the assignment statements inside a Do/ End block.

data want;
   set people;
   if name='Matt' then do;
      age=45;
      salary= 1850;
   end;
run;

If you have a lot of these and the new values are in a data set you have options but that will depend on whether Name, or any combination of variables used to identify a record, only occurs once or multiple times in the data set.

View solution in original post

1 REPLY 1
ballardw
Super User

How many of these records need to be updated? Is the Name duplicated?

 

If you only have a few of these then perhaps an "if" is appropriate: an example with made up values since you did not provide any.

The key with multiple variables is to place the assignment statements inside a Do/ End block.

data want;
   set people;
   if name='Matt' then do;
      age=45;
      salary= 1850;
   end;
run;

If you have a lot of these and the new values are in a data set you have options but that will depend on whether Name, or any combination of variables used to identify a record, only occurs once or multiple times in the data set.