synaptik
synaptik

Reputation: 9509

Modify a single observation in a SAS data set

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.

Upvotes: 3

Views: 19586

Answers (1)

Joe
Joe

Reputation: 63424

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.

Upvotes: 6

Related Questions