Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: RE: command's options as macro
From
tashi lama <[email protected]>
To
<[email protected]>
Subject
RE: st: RE: command's options as macro
Date
Thu, 26 Jul 2012 20:10:38 +0000
First thank you very much. That was very helpful. My apology for not being very clear. When I run
di "`note1'"
note("1 2011" )
tsline hits, "`note1'" from previous post
invalid syntax (which now I understand why)
tsline hits, `note1' as you suggested
invalid varlist
yes, when I type
tsline hits, note("1 2011") stata is happy
----------------------------------------
> From: [email protected]
> To: [email protected]
> Subject: RE: st: RE: command's options as macro
> Date: Thu, 26 Jul 2012 12:54:42 -0700
>
> The value of the macro is not different than what is displayed.
> Display requires that you put text in quotation marks otherwise it tries to
> evaluate the expression as a numeric value. So you use the quotation marks
> with display because it's part of the display syntax for displaying text.
> You'd use the quotation marks even if you were not using a macro.
>
> Whatever context you use it in Stata will expand `note1' as:
> note(" 1 2011" )
> (which, you'll note, IS what was displayed)
>
> If you need that string to be in quotation marks (as with the display
> syntax) you have to put the macro in quotation marks. Otherwise you don't.
>
> You'll have to explain what " i tried without quotation marks still no
> luck." means. What did you type? What error did you get?
>
> My recommendation with when having trouble with these sorts of things is
> always to get the syntax right without macros, then add the macro. So, in
> this case, write out the tsline syntax so it works exactly the way you want
> it to. Then figure out which pieces you can substitute in with a macro.
> So first, does -tsline hits, note("1 2011") - work? If not, figure out why.
> If it does then make sure that the local macro has been defined in the same
> session (remember that if you've just run a dofile that defines a local
> macro you won't be able to access that macro from the command line
> afterwards because that's not the same session from Stata's perspective).
> Then make sure you actually typed the macro right. I'm basically guessing
> at potential problems here since you didn't show what you actually typed.
>
> -Sarah
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of tashi lama
> Sent: Thursday, July 26, 2012 12:37 PM
> To: [email protected]
> Subject: RE: st: RE: command's options as macro
>
> so the value of macro acutally is different than what is being displayed.
> when I say
>
> di "`note1'" I get
> note(" 1 2011" )
>
> isn't note("1 2011") xerox copy of "`note`'"?
>
> i tried without quotation marks still no luck.
>
>
>
> ----------------------------------------
> > From: [email protected]
> > To: [email protected]
> > Subject: st: RE: command's options as macro
> > Date: Thu, 26 Jul 2012 12:17:26 -0700
> >
> > Try without the quotation marks around `note1'
> > If you expand out the macro it's actually tsline hits, "note("1 2011")"
> > The quotation marks around the options isn't valid Stata syntax.
> >
> > Hope that helps.
> >
> > -Sarah
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of tashi lama
> > Sent: Thursday, July 26, 2012 11:58 AM
> > To: [email protected]
> > Subject: st: command's options as macro
> >
> >
> > Hello all,
> > Could someone attempt to explain this to me? I just can't get over
> > this hump.
> >
> > local m1= title[1]
> > local note1 "note" "(" `"" 1 `m1'" "' ")"
> > local note2 1 `m1'
> > di "`note1'"
> > note(" 1 2011" )
> >
> > di "`note2'"
> > 1 2011
> >
> > tsline hits, "`note1'"
> > invalid syntax although if you write it out, it would be tsline hits,
> > note("1 2011") which looks fine tsline hits, note("`note2'") stata is
> > happy
> >
> > Thanx..
> > *
> > * For searches and help try:
> > * http://www.stata.com/help.cgi?search
> > * http://www.stata.com/support/statalist/faq
> > * http://www.ats.ucla.edu/stat/stata/
> >
> > *
> > * For searches and help try:
> > * http://www.stata.com/help.cgi?search
> > * http://www.stata.com/support/statalist/faq
> > * http://www.ats.ucla.edu/stat/stata/
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/