data after;
set before;
*if var1 is laden add one to the new variable;
*this syntax will automatically retain the value of var2;
*and will not give you a missing value if the value of var2 is missing;
if var1='laden' then var2+1;
run;
I haven't run this but it should work.
forgot to put quotes round the literal. Done now.
As I mention in the code comment. The sum statement will automatically retain the variable. You can put the retain in for completeness but it is not required.