Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Transfering multiple data to stata format.


From   [email protected]
To   [email protected]
Subject   Re: st: Transfering multiple data to stata format.
Date   Thu, 1 Sep 2005 20:59:30 -0400

Hi,
Thanks to everyone who took the time to respond
to my mail.

Roger, I've read your mail and take an hour to write
down this code. It's working perfect for the moment
(I can create the log file accessible by dbms copy
and also optionnally call dbms). But I cannot figure
how to open batch directly from stata and run the log
under dbms (from stata).
Any hint, or is it just impossible?

Besides, is there any way to unzip multiple files from stata?
Because the data sets come in a zipped format.

Here is the code. I'll test it for a while and maybe in case
there is no problem, I'll post to the archive. So in case anybody
find a bug or think of improvement, comments are welcomed.

The syntax is:

global path1 "C:\Documents and Settings\Amadou\My
Documents\Archives\data\dhs\data\"
global path2 "C:\Documents and Settings\Amadou\My
Documents\Archives\software\dbmscopy7\"
dbmscopylog dataset1 dataset2 dataset3 , p($path1) l(dbms) d($path2) v(7) c
i(spsswin) o(stata7)

I know, Nick will gonna laugh for my love of global. But I just love global
macros that I can
call everytime I need.

Take care.

Best regards.
Amadou Bassirou DIALLO.
Poverty and Health Specialist
AFTPM, The World Bank.

*********************begin dbmscopylog.ado******************************
cap prog drop dbmscopylog
prog dbmscopylog
version 8
syntax anything, Path(string) Dbmspath(string) Log(string) Version(string)
In(string) Out(string) [ Call *]
token `anything'
cap file close myfile
qui file open myfile using "`path'\`log'.prg", write replace
qui file close myfile
while "`1'" ~= "" {
 qui file open myfile using "`path'\`log'.prg", write append
 file write myfile "compute;" _n
 file write myfile "in='`path'\`1'.`in''" _n
 file write myfile " out='`path'\`1'.`out'';" _n
 file write myfile "run;" _n
 qui file close myfile
 mac shift
}
*Now calling dbms copy
if "`call'"~= "" {
  if "$S_OS"=="Windows" {
    winexec "`dbmspath'\dbmswin`version'"
  }
  else if "$S_OS"~="Windows" {
   winexec `dbmspath'\dbmswin`version'
  }
}
end
exit
*********************end dbmscopylog.ado******************************


                                                                                                                                               
                      Roger Newson                                                                                                             
                      <[email protected]>         To:       [email protected]                                                
                      Sent by:                         cc:                                                                                     
                      owner-statalist@hsphsun2.        Subject:  Re: st: Transfering multiple data to stata format.                            
                      harvard.edu                                                                                                              
                                                                                                                                               
                                                                                                                                               
                      09/01/2005 05:21 PM                                                                                                      
                      Please respond to                                                                                                        
                      statalist                                                                                                                
                                                                                                                                               
                                                                                                                                               
                                                                                                                                               




At 19:21 01/09/2005, Amadou wrote:
>Hi,
>I have several data sets in spss format that I want to convert into stata
>format.
>I am using dbms copy v7 to do the job. But it won't accept multiple inputs.
>It is painfull to select one by one.
>Is there any efficient, faster way to code this?

I myself am a StatTransfer user, mostly because StatTransfer has a DOS
command mode, which made it possible for me to write the -stcmd- package
(downloadable from SSC) as a way for Stata programs to call StatTransfer. I
presume that Amadou doesn't have StatTransfer.

DBMS Copy still doesn't have a DOS command mode (I think). However, I seem
to recall that DBMS Copy has batch files, written in a command language of
its own. Amadou might possibly write one of these batch files, or even
write a Stata program to write one of these batch files.

I hope this helps.

Best wishes

Roger


--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
Division of Asthma, Allergy and Lung Biology
King's College London

5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
   or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]
Website: http://phs.kcl.ac.uk/rogernewson/

Opinions expressed are those of the author, not the institution.

*
*   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/



*
*   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