Reputation: 3099
I tried to recode the missing values but instead lost all my other variables within a dataset
BEFORE:
AFTER:
data work.newdataset;
if (year =.) then year = 2000;
run;
Upvotes: 1
Views: 2148
Reputation: 63424
You are missing the SET statement.
data want;
set have;
myvar=5;
run;
will create a new dataset, want
, from have
, with the new variable value applied (or the recode or whatever). You could also do
data have;
set have;
myvar=5;
run;
That would replace have
with itself plus the recode/whatever. This is actually less common in SAS; it is often preferable to do all recodes in one step, but to create a new dataset (so that the code is reversible easily).
Upvotes: 3