[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: st: RE: Creating a variable from comments/header in a .txt file
Naturally. I would use a local myself.
local file = pl
N.B. Please send just plain text to Statalist.
Thank you for your reply.
I now understand that pl or varname refers to the contents of the varname. I was able to successfully replace the redundant macros in the first half of the do file and save the file using the contents variable pl. . . .
infile using eli2.dct, clear
gen pl=substr(plate,18,6) /* this is data from the first line : in this case "10u5uc"*/
save `=pl', replace
*this then saves the data as 10u5uc.dta
However, I need to read in another set of data, and it appears that the reference to pl disappears
merge obsno using "`=pl'"
pl not found
invalid file specification
Is there a way to save as a global macro and then delete it after I am done with it?
I'll try the easier part of this. Once your filename is in pl
you can refer to that on the fly by `=pl'
so your -merge- command would then be
merge obsno using `=pl', keep(pl)
replace pl ="10u5uc" if _merge==1
would more generally be
replace pl = pl if _merge == 1
if I understand you correctly.
* For searches and help try: