Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: spmap


From   Maurizio Pisati <maurizio.pisati@unimib.it>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: spmap
Date   Sat, 22 Sep 2012 18:58:16 +0200

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index