if i use ''' + $<varname> + ''' for filename as in the example above, i get the following error:

Msg 5105, Level 16, State 2, Line 35
A file activation error occurred. The physical file name '' +@mdf_path+'' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Msg 1802, Level 16, State 1, Line 35
CREATE DATABASE failed. Some file names listed could not be created. Check related...