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]

st: do-file arguments acting weird


From   tashi lama <[email protected]>
To   <[email protected]>
Subject   st: do-file arguments acting weird
Date   Wed, 1 Aug 2012 16:12:12 +0000

Hello all, 
1.   Could someone look into this and educate me? I am kind of lost. I am just copying portion of my dofile here but it should be enough for my question. 
clear 
set more off 
.......
if "`graph_type'"=="line" { 
   if "`measure'"=="peer" { 
         args graph_type is_internal firm_id start_date end_date measure peer_id lag lead    //there are 9 arguments 
         .........
         .........
         if "`10'"=="" {
              tsline hits
              exit 
         }
         else {
               tsline hits1 hits2 
               exit 
         }

   when I execute do file stata always executes the first if(tsline hits) regardless of 9 or 10 arguments although in theory, stata has to execute 2nd if(tsline hits1 hits2) in the case of 10 arguments. However, 
if I modify my argument list 
args graph_type is_internal firm_id start_date end_date measure peer_id lag lead zoom     //zoom is the 10th argument which was absent above 
............
...........
if "`zoom'"==""  {
   tsline hits  
   exit
}
else {
    tsline hits1 hits2
    exit 
}

this time stata does it right. Does anyone have any clue? 

2. If I have a variable date with date in format %tdDDMonCCYY, I have no problem changing to other formats using ( format date %tdCCYYDDMON or format I desire). However, if I have a date in a macro, how can I change the display format. For eg. 

local a 01jan2011
di "`a'" 
01jan2011
if I want `a' in 2011-01-01, then 
format `a' %tdCCYY-DD-NN   (of course stata isn't happy)

Any idea?

Thanx always.  		 	   		  
*
*   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