Hello,
How can I use global macro variable names in folder and file names ? It works when all the macro names are at the end of the expression, but when it is inside, I get error messages.
for instance
The global macro names in the middle of the filename are not working($yrsilc and $agemin); the last one is working ($agemax).
I have also tried to put . , {} , but it did not work neither. I suppose there is a sign for terminating the macroname ? like in SAS the .
Thank you in advance, Françoise
How can I use global macro variable names in folder and file names ? It works when all the macro names are at the end of the expression, but when it is inside, I get error messages.
for instance
Code:
***Without macros (to show what I would like to do)
use "X:\HLE\SILC\Prep SILC data\FR\Further_steps\2006\Prep_data_06.dta",clear
/*here 2 command lines without problems */
*stset DOE, fail(event==1) id(ID_$yrsilc) origin(DOB) enter(date_surv) scale(365.25)
*stsplit curage, at(16(1)85)
save "X:\HLE\SILC\Prep SILC data\FR\Further_steps\2006\STsplit_Noweight_06_15_95.dta", replace
********WITH macros, I have tried this:
global yrsilc "06"
global agemin "16"
global agemax "85"
use "X:\HLE\SILC\Prep SILC data\FR\Further_steps\20$yrsilc\Prep_data_$yrsilc.dta",clear
****command lines
save "X:\HLE\SILC\Prep SILC data\FR\Further_steps\20$yrsilc\STsplit_Noweight_$yrsilc_$agemin_$agemax.dta", replace
HTML Code:
file X:\HLE\SILC\Prep SILC data\FR\Further_steps\2006\STsplit_Noweight_95.dta saved
I have also tried to put . , {} , but it did not work neither. I suppose there is a sign for terminating the macroname ? like in SAS the .
Thank you in advance, Françoise

Comment