Bookmark and Share

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: using macros in label define


From   Barry Quinn <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: using macros in label define
Date   Thu, 26 Apr 2012 19:04:19 +0100

Nick
 
Sorry for late reply and the "issue" phrasing.  The only issue is my poor coding knowledge :)

As you suggested i was feeding an unacceptable definition.

You suggestion works perfectly

thanks

Barry Quinn
________________________________________
From: [email protected] [[email protected]] On Behalf Of Nick Cox [[email protected]]
Sent: Wednesday, 25 April 2012 6:39 PM
To: '[email protected]'
Subject: RE: st: using macros in label define

Jonathan's advice is incorrect. I think he is confusing variable label and value label definition.

There is no "issue" here. My guess is that you are feeding an unacceptable definition to -label define- because the " " etc. get transferred.

Try

loc def `def' `z' "`x'"

Nick
[email protected]

Jonathan Cantor

Put the define object in quotes
la def type "`def'"

On Wed, Apr 25, 2012 at 1:25 PM, Barry Quinn <[email protected]> wrote:

> I am getting an invalid syntax message when using a local in -label define-.
> Here is my code:
>
> *DEFINE GROUP VARIABLES
> *TYPE
> sort B_Type
> gen type=lower(trim(subinstr(B_Type," ","",.)))
> egen typ=group(type)
> la var typ "Type of Institutions"
> save tmp1, replace
> keep if type!=type[_n+1]
> levelsof type, loc(type) clean
> loc z=0
> loc def ""
> foreach x of loc type{
> loc ++z
> loc def `def' `z' " " `""`x'""' " "
> }
> use tmp1, clear
> la def type `def'
> la li type
> la val typ type
>
> I may be missing something obvious but i was wondering is there an issue with use macros in label define ?

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index