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]

Re: st: Census/Demographics Datasets


From   Michael Stewart <[email protected]>
To   statalist <[email protected]>
Subject   Re: st: Census/Demographics Datasets
Date   Mon, 6 Jan 2014 04:15:24 -0500

HI Roberto, Samuel and Nick,

It worked!!.
 Thank you very much for your time.  Obviously, I couldnt have written
that code!.
I never expected that stata could copy/download and unzip too .
I think, I can take it from here.  Thank you again  for your time.


On Mon, Jan 6, 2014 at 3:11 AM, Roberto Ferrer <[email protected]> wrote:
> I think Steve Samuels pointed you in the right direction. As suggested
> in two of those pages, you can try using -copy- and -unzipfile- to
> download all the data to your local drive and unzip it. Afterwards,
> you can worry about importing it to Stata. The "readme" file
> indicates:
>
> "We are unable to provide one-on-one support for applications of the
> data to specific spreadsheets or
> data base software."
>
> So my quick guess is unless someone has already done it and made the
> files public, you won't find them as Stata data files.
>
> Also,
>
> "Once the package is unzipped, the files are in flat ASCII format."
>
> So that gives you a head-start on the importing task.
>
> Anyway, for the downloading and unzipping you can try:
>
> *--------------- begin code --------------------
>
> clear all
> set more off
>
> local sitestub "http://www2.census.gov/census_2010/04-Summary_File_1/";
> local states Alabama Alaska
> local statesabb al ak
>
> local targetdir "~/Desktop/data/"
>
> local n : word count `states'
>
> forvalues i = 1/`n' {
>     local a : word `i' of `states'
>     local b : word `i' of `statesabb'
>
>     display `"`sitestub'`a'/`b'2010.sf1.zip"'
>     copy `"`sitestub'`a'/`b'2010.sf1.zip"'  `targetdir'
>
>     display `"`targetdir'`b'2010.sf1.zip"'
>     unzipfile `"`targetdir'`b'2010.sf1.zip"'
> }
>
> *--------------- end code -----------------------
>
> This may work because the URL has a fixed structure. Something like:
>
> http://www2.census.gov/census_2010/04-Summary_File_1/STATE/STATE-ABBREVIATION-2010.sf1.zip
>
> So create a list of USA states and their abbreviations, save that into
> macros, and using extended macro functions,
> loop to create links for each state and download. The code above has
> two states and two abbreviations. You need to complete it (easily done
> with an internet search) and change the macro -targetdir- to your
> desired target directory. The -display-s are just there so you can
> check the links that are being created.
>
> See -help macro-, -help extended_fcn-, -help copy-, help unzipfile- and
>
> http://www.stata.com/support/faqs/programming/looping-over-parallel-lists/
>
> On Sun, Jan 5, 2014 at 10:45 PM, Michael Stewart
> <[email protected]> wrote:
>> HI  ,
>>
>> I am not sure if I understand your answers properly and I apologize if
>> there is any confusion.
>>
>> I am looking for demographic details of USA(as a whole) and individual
>> states. The procedure recommended by census.gov website seems to be
>> cumbersome(http://www.census.gov/2010census/news/press-kits/summary-file-1.html)
>> i.e.,I have to download the census files for each individual state
>> (total 52 times) to get census of USA .
>>
>> Therefore, I was requesting if any stata list subscriber would know of
>> an easier, less cumbersome method to download the datasets directly
>> over the internet(preferably in stata format).
>>
>> Please let me know if  know any link/website where I can download such
>> datasets .
>>
>> Thank you again for your time .
>>
>> On Sat, Jan 4, 2014 at 11:22 PM, Steve Samuels <[email protected]> wrote:
>>>
>>> Michael Stewart <[email protected]>:
>>>
>>> There is related information at:
>>>
>>> 1. http://stackoverflow.com/questions/19498050/stata-python-downloading-
>>> files-from-a-ftp-site-in-stata-or-in-python (The accepted answer was
>>> supplied by a well-known Statalister.)
>>>
>>> 2. www.stata.com/statalist/archive/2007-01/msg00852.html
>>>
>>> 3. http://blog.stata.com/2010/12/01/automating-web-downloads-and-file-
>>> unzipping/
>>>
>>> If files are not in Stata format, you can run StatTransfer commands in
>>> Stata via -shell-.
>>>
>>> Steve
>>>
>>>
>>>
>>> On Jan 4, 2014, at 8:09 PM, Nick Cox wrote:
>>>
>>> You could start with the help for -use-. The very first example shows
>>> -use- in play reading a .dta file over the internet. The same
>>> principles apply to other forms of data file.
>>>
>>> Nick
>>> [email protected]
>>>
>>>
>>> On 4 January 2014 19:41, Michael Stewart
>>> <[email protected]> wrote:
>>>
>>>> Is there a way to download Census/demographics datasets  from Internet
>>>> to stata directly . Thank you very much for your time.
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
>>> *   http://www.ats.ucla.edu/stat/stata/
>>
>>
>>
>> --
>> Thank you ,
>> Yours Sincerely,
>> Mike.
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/



-- 
Thank you ,
Yours Sincerely,
Mike.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index