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]

From |
"Sarah Edgington" <sedging@ucla.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of tashi lama Sent: Thursday, July 26, 2012 12:37 PM To: statalist@hsphsun2.harvard.edu 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: sedging@ucla.edu > To: statalist@hsphsun2.harvard.edu > 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: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of tashi lama > Sent: Thursday, July 26, 2012 11:58 AM > To: statalist@hsphsun2.harvard.edu > 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/

**Follow-Ups**:**RE: st: RE: command's options as macro***From:*tashi lama <ltashi32@hotmail.com>

**References**:**st: command's options as macro***From:*tashi lama <ltashi32@hotmail.com>

**st: RE: command's options as macro***From:*"Sarah Edgington" <sedging@ucla.edu>

**RE: st: RE: command's options as macro***From:*tashi lama <ltashi32@hotmail.com>

- Prev by Date:
**Re: st: drop variables with missing values** - Next by Date:
**RE: st: RE: command's options as macro** - Previous by thread:
**RE: st: RE: command's options as macro** - Next by thread:
**RE: st: RE: command's options as macro** - Index(es):