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: width() invalid error when using a local macro to loop over years


From   Diederik van Liere <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: width() invalid error when using a local macro to loop over years
Date   Thu, 6 Jan 2011 17:27:50 -0500

Dear statalist members, 

I would like to dynamically generate dates for a simple macro. The dataset contains two variables: experience and date. Experience is a simple count variable and date is the date of observation. I would like to generate a number of histograms for different years.  The current code to do this looks:


forvalues year = 2001(1)2011 {
	histogram experience if date==mdy(1, 30, `year'), discrete percent 
}

However, this does not work. Stata raises the following error:
	width() invalid -- invalid number, outside of allowed range.  
I am not quite sure why this is the case, wrapping the year variable like "`year'" does not solve the problem either. 

Any suggestions on how to fix this?

Best regards,


Diederik

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