Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: aggregating data & local macros


From   "mac.stata" <[email protected]>
To   [email protected]
Subject   st: aggregating data & local macros
Date   Fri, 30 May 2008 21:56:00 +0200

Dear all,

As some of you have already noticed I am more of a beginner with Stata and therefore confront you most likely with pretty basic questions. Nevertheless, some have already helped me quite a bit (many thanks!)! But, unfortunately, there are two other questions right at my side:

1. aggregating data
I have records of individuals on the community level and these should be matched with data on the district level (I have district numbers I can match; I will use "joinby"). Which is the right way to go: a) have the two data sets put together with "joinby" and then try using "collapse" to aggregate the data on a district level (and then regress the data on the district level) or b) again–on the community level–put the data sets together first but then work with the Stata command "xi: ... ... ... i.districts"? As these are records of individuals containing socio-economic data it might get very difficult when using "collapse", I think. So, is the "xi:" actually the right way to go? Will this in any way cause troubles (from a scientific view of the approach)?

2. local macro
I wanted to create a local macro containing all variables to be used. So, instead of having << use A B C D E ... Z using "data.dta" >> I would like to have << use `local_var' using "data.dta" >>. The list of variables to use is long (about 30 to 40 variables, obviously less though than the ones I want to kick out, so no need for "drop"). Now, because it is a long list of variables I wanted to manually use line breaks. I therefore used the "#delimit ;" and "#delimit cr" before and after the definition of the local macro << local local_var = " A B C D ... Z" >>. I thought this performs fine, also because I did not get any error but when I checked if all went right, it showed that after the third (of about five) line breaks the variables were ignored. So, Stata did recognize the local macro but it seems the local macro only contains about the first three lines of the variables I included. What am I doing wrong here? (I now use the "delimit" command within the standard "use" command which works fine).

Many thanks for your great help!

Andrea


*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index