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: Running a model using global macro statement


From   "Eric A. Booth" <[email protected]>
To   [email protected]
Subject   Re: st: Running a model using global macro statement
Date   Tue, 3 Sep 2013 10:16:29 -0500

<>

Apologies, I hit 'send' early on my last email.... the last point was
showing how your model runs once you strip away the double compound
quotes, consider:


 global regtype logit
 global dependentvar event90
 global collection2 i.zipspecial i.date
 global zipind dage1-dage8

global regressionstatement "$regtype" "$dependentvar" " "
"collection2" " " "$zipind" " "
di "${regressionstatement}" // versus:
di `"${regressionstatement}"'
*! this is not what you want.

****instead try this
global regressionstatement  $regtype $dependentvar $collection2 $zipind

di `"${regressionstatement}"'
${regressionstatement} //this works.


- Eric


On Tue, Sep 3, 2013 at 10:13 AM, Eric A. Booth <[email protected]> wrote:
> <>
> This a issue with the quotes. Your global regressionstatement doesnt
> need all those quotes around the globals, nor the extra set of quotes
> to embed spaces.  First, you should read the -help quotes- file about
> double compound quotes because it's useful anytime you are working
> with macros that contain multiple quotes or nested quotes as you are
> attempting to do.  But in this case the issue is that you just do not
> need quotes at all.  Nesting your globals in the
> ${regressionstatement} without quotes will insert the proper spaces.
>
> So
>
>
>
>
> On Tue, Sep 3, 2013 at 9:45 AM, Sam Asin <[email protected]> wrote:
>> Hello, this is my first post here!
>>
>> I am trying to create a do file that runs a logit command.  I use a
>> global macro statement to set up the regression, it's called
>> $regressionstatement.
>>
>> global regressionstatement "$regtype" "$dependentvar" " "
>> "collection2" " " "$zipind" " " "$dateind" " " "$kenparam"
>> "$ifstatement" ", " "$options"
>>
>>
>>
>> At the bottom of my code, it invokes $regressionstatement.  However, I
>> get this error:
>>
>> 2" " invalid name
>> r(198);
>>
>>
>>
>> However, if I write:
>>
>> display "$regressionstatement"
>>
>>
>> and then copy paste the output onto my command line and run it, it
>> works.  I also tried:
>>
>> "$regressionstatement"
>>
>> to no avail, as well as:
>>
>> global test "$regressionstatement"
>>
>> $test
>>
>> How can I make my code run the regressoin statement that I've made
>> without requiring the additional manual input?  For what it's worth,
>> I've included the code of interest below.
>>
>>
>>
>>
>> global regressionstatement "$regtype" "$dependentvar" " "
>> "collection2" " " "$zipind" " " "$dateind" " " "$kenparam"
>> "$ifstatement" ", " "$options"
>>
>>  display "$regressionstatement"
>> logit event90 collection2 i.zipspecial i.date dage1-dage8 cohort96
>> cohort97 cohort98 cohort99 cohort00 cohort01 cohort02 cohort03
>> cohort04 cohort05 cohort06 cohort0
>>> 7 cohort08 ltv1 ltv2 ltv3 ltv4 ltv5 fico1 fico2 fico3 fico4 xfc11 xfc12 xfc13 xfc14 xfc21 xfc22 xfc23 xfc24 xfc31 xfc32 xfc33 xfc34 xfc41 xfc42 xfc43 xfc44 oupb1-
>>> oupb4 fdti1 fdti2 fdti3 fdti4 bdti1 bdti2 bdti3 bdti4 sato1-sato2  second_lien metro units condo if def_obs_count<2, vce(robust)
>> .
>> $regressionstatement
>> 2" " invalid name
>> logit event90 collection2 i.zipspecial i.date dage1-dage8 cohort96
>> cohort97 cohort98 cohort99 cohort00 cohort01 cohort02 cohort03
>> cohort04 cohort05 cohort06 cohor
>>> t07 cohort08 ltv1 ltv2 ltv3 ltv4 ltv5 fico1 fico2 fico3 fico4 xfc11 xfc12 xfc13 xfc14 xfc21 xfc22 xfc23 xfc24 xfc31 xfc32 xfc33 xfc34 xfc41 xfc42 xfc43 xfc44 oupb
>>> 1-oupb4 fdti1 fdti2 fdti3 fdti4 bdti1 bdti2 bdti3 bdti4 sato1-sato2  second_lien metro units condo if def_obs_count<2, vce(robust)
>> note: 33890.zipspecial != 0 predicts success perfectly
>>       33890.zipspecial dropped and 60 obs not used
>>
>> etc.
>>
>>
>> Thanks!
>>
>> Sam
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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