A single data step can create as many output data sets as you want. It is important to remember all output data sets are created, and the columns of the output are fixed at run-time. You can specify which variables of the pdv should be in each output data set by using the data set option (keep=...) or (drop=...). In a single data step you can not create an output data set whose name is based on some variables value -- you can preprocess the data if you need such a splitting. There are some trickeries that involve dynamic hashes, but that is an advanced topic
The if statements you are currently using are sub-setting ifs. This means output (an implicit output) only occurs when the data step flow reaches the bottom of the step. You will want an explicit OUTPUT statement to ensure the current row goes into the desired output data set.
Thus you could have a data step similar to
data want1 want2(drop=total);
merge one two;
by key;
if missing(quantity) then
OUTPUT want2;
else do;
total = quantity * price;
OUTPUT want1;
end;
run;