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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top