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.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1571 views
  • 0 likes
  • 2 in conversation