Modify a single observation in a SAS data set

datastep, sas

Solution

The simple case:

data want;
set people;
if name='Mark' then age=31;
run;

You can change it in the same dataset a number of ways:

proc sql;
  update want 
    set age=31 
    where name='Mark';
quit;


data people;
set people;
if name='Mark' then age=31;
run;


data people;
modify people;
if name='Mark' then age=31;
run;

etc.

Problem

Suppose I have the following data set: ``` data people; input name $ age; datalines; Timothy 25 Mark 30 Matt 29 ; run; ``` How can I change the age of a particular person? Basically, I want to know how to specify a `name` and tell SAS to change that person's (observation's) `age` value.

Original source