First of all thanks for the answer. I think I see your point but my problem is that there are guidelines in the assignment I have to do. Earlier in the code we have to do the same task of writing missing values forward using a retain statement what lead me to retain _ask; if ask ="." then ask = _ask; else _ask = ask; drop _ask; and it does what it is supposed to do. Problem is another task wants me to do the same using this macro variable. The text of the task: "12. Again, merge the sorted datasets sorted_spread and sorted_transaction in a data step. However, now associate the transaction price with the bid-ask-spread at the beginning of the subsequent second after the trade. To do so, use the macro write_forward to write all the variables from the transaction dataset forward. Inparticular, the macro write_forward replaces the missing values of the variables. The list typelist specifies whether missing values are encoded with a dot.(numeric variables) or an emptystring""(character variables). /* Example for a call of the macro*/ %write_forward(varnames=char_var1 num_var1 char_var2 ,typelist="" . ""); After that, remove all the observations that still contain missing values in any of the variables price, ask, or bid. Perform all of these steps in a single data step. Call the resulting dataset forward." I thought the easiest way to do it would be using what I did before and just put it in a macro variable. And about the retain statement I thought I just use a new variable called _ask that remembers the last missing value and if the value in the original variable is missing it is replaced by the new _ask variable. If its not missing the _ask variable takes on the new value that is now the last non-missing one. At the end the new variable _ask is dropped because its pretty much only a helping hand. I hope this at least explains what I was doing.
... View more