I wrote an sclass program which returns two variable lists in separate macros:

Code:
capture program drop model_select
program define model_select, sclass

    syntax, cenyear(integer) filename(string)

    ** Read
    use "${DATA}/dta/`filename'", clear
    
    ** FE ID's
    egen state_year = group(state_code_`cenyear' year)
    egen distid = group(c_code_`cenyear')
    
    ** Controls
    local weather temperature_mean rainfall_mean
    
    ** Residualize
    reghdfe capgw_dist_cum capgw_state_cum_pred, ///
        a(c_code_`cenyear'_num month state_code_`cenyear'_num#year) ///
        vce(cl state_code_`cenyear'_num#year) residuals(resid_capgw_dist_cum)
            
    ** Standard LASSO (K-Fold CV)
    lassoregress resid_capgw_dist_cum psc_*
    sreturn local lasso_ivs "`e(varlist_nonzero)'"

    ** RLASSO (Heteroskedasticity-Robust)
    rlasso capgw_dist_cum psc_* ///
        i.distid i.month i.state_year capgw_state_cum_pred `weather', robust ///
        partial(i.distid i.month i.state_year capgw_state_cum_pred) ///
        pnotpen(`weather') cluster(state_year) supscore
    sreturn local rlasso_ivs "`e(selected)'"

end
Running sreturn list after the program ends confirms that s(lasso_ivs) and s(rlasso_ivs) hold the correct variables. However, later on I want to run two IV regressions with all variables in each s() as instruments.

Code:
foreach model in lasso_ivs rlasso_ivs  {
    reghdfe so2_ln capgw_state_cum_pred ///
        (capgw_dist_cum =  " `s(`model')' "), ///
        a(c_code_2011_num month state_code_2011_num#year) vce(cl state_code_2011_num#year old
I get an error varlist required r(100). I believe the issue is with the quotations -- the varlist saved in the s() from the program is not being inserted. I've tried several variations of quotes including "s(`model')", `s(`model')', but nothing seems to work. Any ideas? Thanks