A couple comments / questions:
1. Your message is very hard to read because of stuff like " I=E2=80=99m
trying "
2. -spmap- supersedes -tmap-
3. Are you using data from http://www.census.gov/geo/www/cob/mmsa2003.html?
4. When you use -shp2dta- on cb99_03b.shp (assuming the answer to question
3 is yes) does the database file contain the cbsa names? When I try
-shp2dta- on this data set the names are not picked up:
. which shp2dta
c:\ado\plus\s\shp2dta.ado
*! version 1.0.2 30mar2006
. //Data from http://www.census.gov/geo/www/cob/mmsa2003.html
. clear
. cd "C:\Documents and Settings\Scott_2\Desktop\foo"
C:\Documents and Settings\Scott_2\Desktop\foo
. shp2dta using cb99_03b.shp, database(usdatabase2)
coordinates(uscoordinates2) genid(id) replace
. use usdatabase2
. l in 1/3, noobs
+-------------------------------------------------+
| CBSA CBSA_N~E TYPE STATUS GEOCODE id |
|-------------------------------------------------|
| 21820 1 |
| 11260 2 |
| 27940 3 |
+-------------------------------------------------+
.
end of do-file
5. Does your uscoordinates2.dta file contain variables such a
numberoffreeclinics and validcbsa? If not, then you not could not have
simply renamed (and moved it from "\Desktop\cb99_03b_shp\" to "E:\Data\" )
the file and used -tmap-.
6. I don't know if this will help you, but since I could not get -shp2dta-
to pull in the names I used the ASCII data file (cb99_03ba.dat) to get the
cbsa names and merged it with the uscoordindates.dta. The following seems
to work:
//Data from http://www.census.gov/geo/www/cob/mmsa2003.html
clear
cd "C:\Documents and Settings\Scott_2\Desktop\foo"
shp2dta using cb99_03b.shp, database(usdatabase2) ///
coordinates(uscoordinates2) genid(id) replace
use usdatabase2
l in 1/3, noobs
gen x = uniform()
rename CBSA cbsa
keep cbsa id x
sort cbsa
save, replace
insheet using "cb99_03ba.dat",clear
egen index2 = fill(1 2 3 4 5 1 2 3 4 5 )
egen index = seq(), block(5)
reshape wide v1, i(index) j(index2)
compress
drop v11
rename v12 cbsa
rename v13 cbsa_name
rename v14 type
rename v15 geocode
gen state = substr(cbsa_name,-2, 2)
gen type2 = "micro" if type == "2"
replace type2 = "metro" if type =="1"
drop if cbsa==" "
duplicates drop cbsa cbsa_name type, force
sort cbsa
save "names.dta", replace
merge cbsa using usdatabase2.dta
tab _m
drop index _m
sort id
mark conterminous if state != "HI" & state != "AK" & state != "PR"
spmap x if conterminous & type2 == "metro" using "uscoordinates2" , ///
id(id) ndfc(white) fc(Blues) ocolor(gs12 ..)
Or as a middle of the country example:
spmap x if state == "MO" & type2 == "metro" using "uscoordinates2" , ///
id(id) ndfc(white) fc(Blues) ocolor(gs12 ..)
Scott
> -----Original Message-----
> From: Julie Susan Darnell [mailto:[email protected]]
> Sent: Monday, February 26, 2007 1:11 AM
> To: [email protected]
> Subject: st: tmap using core-based statistical areas
>
> J15660
> Sender: [email protected]
> Precedence: bulk
> Reply-To: [email protected]
> Errors-To: [email protected]
> I=E2=80=99m having trouble executing the tmap commands. I=E2=80=99m trying
> =
> to
> create a map using core-based statistical area (CBSA) boundary
> files.
>
> First I converted shape and database files from the Census
> using the following syntax:
>
> shp2dta using "C:\Documents and
> Settings\Desktop\cb99_03b_shp\cb99_03b.shp",
> database(usdatabase2) coordinates(uscoordinates2) genid(id)
>
> I renamed usdatabase2 tmap3.
>
> Then I executed the following syntax:
>
> use "E:\Data\tmap3.dta"
> #delimit;
> tmap choropleth numberoffreeclinics if validcbsa=3D=3D1 &
> msa!=3D11260 & msa!=3D26180 & msa!=3D21820, id(id)
> map("C:\DATA\uscoordinates2.dta")
> palette(Blues) ocolor(white) osize(medium)
> legbox legtitle("# of free clinics") legformat("%4.1f") legpos(5);
>
> Note: the =E2=80=9Ctmap3.dta=E2=80=9D file is my main file and the
> =E2=80=9Cuscoordinates2.dta=E2=80=9D is the boundary file. I=E2=80=99m
> inte=
> rested in
> showing only the metropolitan areas, not the micropolitan
> areas of the CBSAs. The variable validcbsa excludes those
> cbsa=E2=80=99s that are designated neither as metropolitan nor
> division areas.
>
> I don=E2=80=99t receive any error messages but when the graph is
> produced only the areas around the edges of the United States
> appear. Parts of FL, WA, OR, MI, and ME and the lower SE of
> the United States appear. The entire middle of the country is
> blank.
>
> Any ideas about what might be causing this problem and how I
> can fix it?
>
> Thank you!!
>
> Julie Darnell
>
*
* 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/