I suggest using SAS proc import, which is very flexible, like this:
. sysuse auto.dta
(1978 Automobile Data)
. outsheet _all using test.txt, comma replace noquote
proc import datafile="C:\DATA\test.txt"
out=work.test
dbms=dlm
replace;
delimiter=",";
getnames=yes;
run;
Hope this helps, Tim
On 9/29/07, juzhi wang <[email protected]> wrote:
> I have listened to Rodrigo's advice. And I did export my stata file into excel. But one of the data file has too many variables and I am not allowed to do completely transfer ( I guess the number of variables has exceeded the Excel limit). Only about half of the varialbes have been transfered. Could anybody give me further advice?
>
> Thanks,
>
> ----- Original Message ----
> From: Rodrigo Martell <[email protected]>
> To: [email protected]
> Sent: Friday, January 12, 2007 2:01:01 AM
> Subject: RE: st: from stata to SAS
>
>
> Hi Juzhi,
>
> A free alternative to Michael's suggestion (I think you have to pay for StatTransfer):
>
> I don't know anything about SAS but I assume it can read in csvs (?).
>
> If so then an easy way would be to open the Stata file you're interested in and type this (I'll send it to your C drive):
>
> outsheet using "C:\Stata_to_Sas.csv", comma replace
>
>
> The above will spit out a csv file which Excel can read, but if SAS reads csvs you could just skip the Excel bit and go straight to SAS.
> How many Stata files do you need to translate?
> If you need to do more than would be feasible for manual typing of the above suggestion you could create a do file
> (in Stata, click on the toolbar icon with a little hand and a pencil over a piece of paper), copy and paste the below code and run it by clicking either of the buttons with the downward pointing arrows.
> In the code below I assumed you have 2 files (stata1.dta and stata2.dta) you want to spit out as csvs. The path where these files live I assumed to be "C:/", you can change the path (leave in the quotation marks and make sure the last slash before `name' is a forward slash, the rest can be either back or forward, Stata understands both e.g C:/MyFolder/MySecondFolder/ = C:\MyFolder\MySecondFolder/).
>
> ------Copy from line below
> capture program drop stata_sas
> program define stata_sas
> syntax namelist
> foreach name of local namelist{
> use "C:/`name'.dta", clear
> outsheet using "C:/`name'.csv", comma replace
> }
> end
>
> stata_sas stata1 stata2
> ----end copy at above line
>
> If you want to add more Stata files just add the names of the files to the last line of the code.
>
> I hope this is of some help.
>
> Cheers,
>
> Rodrigo
>
> Rodrigo Martell
>
> <http://www.frontier-economics.com>
> Frontier Economics Pty. Ltd.
> 395 Collins Street
> Melbourne VIC 3000
> Australia
> www.frontier-economics.com
> switch:
> direct:
> fax:
> mobile:
> email:
>
>
> +61 (0)3 9620 4488
> +61 (0)3 9613 1518
> +61 (0)3 8614 2711
> +61 (0)407 909 811
> [email protected] <mailto:[email protected]>
>
>
> This e-mail, including any attachments, may contain confidential and privileged information for the sole use of the intended recipient(s). Any review, use, disclosure or distribution by others is strictly prohibited. If you are not the intended recipient (or authorised to receive information for the recipient), please contact the sender by reply e-mail and delete all copies of this message. Thank you.
>
>
>
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Michael
> McCulloch
> Sent: Friday, 12 January 2007 4:41 PM
> To: [email protected]
> Subject: Re: st: from stata to SAS
>
>
> Juzhi,
> A software called Stat-transfer can do this without any SAS -or Stata- code.
> (http://www.stattransfer.com/).
> Michael
>
>
>
>
>
> At 08:25 PM 1/11/2007, you wrote:
> >Hello Everybody:
> >
> >I am a SAS user. I do not know anything about Stata. But I need to import
> >Stata data sets to SAS. What I need to do is to export the Stata into
> >Excel and from Excel to SAS. Could anybody in the list provide a block of
> >code to help me export the Stata dataset to Excel?
> >
> >Thanking you very much in advance,
> >Juzhi
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Tired of spam? Yahoo! Mail has the best spam protection around
> >http://mail.yahoo.com
> >
> >*
> >* 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/
>
>
> Best wishes,
> Michael
>
>
> ____________________________________
>
> Michael McCulloch
> Pine Street Clinic
> Pine Street Foundation
> 124 Pine Street, San Anselmo, CA 94960-2674
> tel 415.407.1357
> fax 415.485.1065
> email: [email protected]
> web: www.pinest.org
> www.pinestreetfoundation.org
> www.medepi.net/meta
>
>
>
>
>
> *
> * 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/
>
>
> Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail at http://mrd.mail.yahoo.com/try_beta?.intl=ca
>
>
> *
> * 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/