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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 1936 views
  • 0 likes
  • 2 in conversation