# \isdefempty not working for multiple macros

I am still learning tex. The following example allows me to check if a variable exists, and if it does then prints some text in the PDF. This works great. However, when I add in a href, this appears whether the variable exists or not. Driving me nuts as I cant find anything online even close to what im trying to do. Is it even possible?

\ifdefempty{\na}{}{\Sexpr{cve_descr_na}}\ is displaying a variable I have in R. This works well. However, \ifdefempty{\ds}{}{\Sexpr{cve_descr_ds}{\href{\Sexpr{url_ds_1}}{here }}}\ displays "here" even if ds is null.

\documentclass[11pt,a4paper, titlepage]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{tikz,fancyvrb}
\usepackage{helvet}%font
\usepackage{color}
\usepackage{etoolbox}
\def\ds{cve_descr_ds}
\def\ui{cve_descr_ui}
\renewcommand{\familydefault}{\sfdefault}%sets fonts across document
\title{}
\date{}
\begin{document}
\fcolorbox{white}{green!65}{%
\parbox{17cm}{
\small
\ifdefempty{\na}{}{\Sexpr{cve_descr_na}}\\
\ifdefempty{\spf}{}{\Sexpr{cve_descr_spf}}\\
\ifdefempty{\ds}{}{\Sexpr{cve_descr_ds}{\href{\Sexpr{url_ds_1}}{here }}}\\
\ifdefempty{\ui}{}{\Sexpr{cve_descr_ui}{\href{\Sexpr{url_ui_1}}{here,}}}\\
}
}
\end{document}


Here is the resultant sweave; \documentclass[11pt,a4paper, titlepage]{article} \usepackage[margin=0.5in]{geometry} \usepackage{tikz,Sweave,fancyvrb} \usepackage{helvet}%font \usepackage{color} \usepackage[hidelinks]{hyperref} \usepackage{etoolbox} \def\ds{cve_descr_ds} \def\ui{cve_descr_ui}

\renewcommand{\familydefault}{\sfdefault}%sets fonts across document
\title{}
\date{}
\begin{document}
\input{HC-concordance}
\fcolorbox{white}{blue!65}{%
\parbox{5cm}{
\begin{center}
\small
The Lakes
\\
\end{center}
}
}
\fcolorbox{white}{green!65}{%
\parbox{13cm}{

• Besides you are missing the } for \fcolorbox. We need to know what \Sexpr is doing, and it might not be compatible with hyperref expansion. – daleif Dec 8 '17 at 14:53
• But … \ds isn't empty in your document! – Harald Hanche-Olsen Dec 8 '17 at 15:10