Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Lynn Lee" <lynn09v@gmail.com> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | st: spmap |
Date | Sun, 23 Sep 2012 11:01:18 +0800 |
Dear Prof. Pisati, I greatly appreciate for your kind and detailed explanation to my question. Your suggestion is a very good guidance for a learner. Best Regards, Lynn Lee -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Maurizio Pisati Sent: Sunday, September 23, 2012 12:58 AM To: statalist@hsphsun2.harvard.edu Subject: Re: st: spmap Dear Lynn, it takes a careful reading of the help file and a little bit of experimentation for getting the desired results with -spmap- -- admittedly, not the easiest Stata command to use. As you correctly noticed, suboption -label()- of option -label()- accepts only one variable. So, how can one plot the labels stored in two different variables? In Stata terms, to solve this problem one must move from a -wide- to a -long- perspective. In practice, this means to generate two variables: (a) one -- the "labvar_lb" variable in -spmap- parlance -- will store all the desired labels, stacked over each other; (b) the other -- the "byvar_lb" variable in -spmap- parlance -- will store a label identifier (taking, e.g., value 1 for the first set of labels, value 2 for the second set of labels, and so on). Once we have the "labvar_lb" and "byvar_lb" variables, we can use -spmap- as usual. Here's an example using the datasets that come with -spmap-: . use "Italy-RegionsData.dta", clear . generate labtype=1 . append using "Italy-RegionsData.dta" . replace labtype = 2 if labtype==. . generate label = region if labtype==1 . replace label = string(relig1,"%4.1f") if labtype==2 . keep xcoord ycoord label labtype . save "Labels.dta", replace . use "Italy-RegionsData.dta", clear . spmap using "Italy-RegionsCoordinates.dta", id(id) label(data("Labels.dta") x(xcoord) y(ycoord) /// label(label) by(labtype) size(*0.7 ..) position(12 0)) Best wishes, Maurizio Il giorno 22/set/2012, alle ore 15.26, Lynn Lee ha scritto: > Dear Prof. Pisati, > > I am really sorry, but I still do not fully understand the -by()- option. > -label()- option only allows one variable in bracket, -by()- is to > group labels, but I do not want to group them. I have two variables > "ename" and "GDP" to be labeled, if I write -label(label(ename) > label(GDP))-, it is wrong. If I write -label(label(ename) by(GDP))-, > it shows ename only, no GDP value added on the map. From definition > of -by()-, it should be possible to add more than one labels. But I do > not know how to add another label correctly. Could you please give me some suggestion? > > Best Regards, > Lynn Lee > > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Maurizio > Pisati > Sent: Saturday, September 22, 2012 7:30 PM > To: statalist@hsphsun2.harvard.edu > Subject: Re: st: spmap > > Dear Lynn, > yes, it's possible, you can plot as many different labels as you like > using suboption -by()- of option -label()-. See the -spmap- help file > for exact syntax and details. > Best wishes, > Maurizio > * * 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/