Complex bash/sed, variables and nested quotes

Ok, this one isn't for everybody, it's pretty tough and I've spent a good deal of time on it without figuring it out yet.

Can anybody get this script to work:

    #!/bin/bash
    
    cq_fname="%let outputfile="/user/cq_"$1".csv";"
    
    sed "29s/.*/\"$cq_fname\"/" file1.sas > file2.sas

$1 is usually a date. Basically, I'm trying to replace line 29 of file1.sas with:
%let outputfile="/user/cq_20060104.csv";

awk 'NR==29 { print L ; next } 1' L="%let outputfile=\"/user/cq_${1}.csv\";" inputfile > outputfile

Hi, try:

cq_fname="%let outputfile=\"/user/cq_$1.csv\";"

sed "29s|.*|$cq_fname|" file1.sas > file2.sas

yup, that works!