Thursday, August 5, 2010

STATA & SAS: Life without STATRANSFER

Let's pretend for a second: The evil software overlord, let's call him Dr. Mulcahy because that sounds sinister, won't release a copy of STATransfer to you. Even as you plead "But great and wonderful Dr. Mulcahy, I really need to get my data from SAS to STATA!!!"

"No!" he bellows in his fractious Greek way.

You stumble off humiliated and ashamed, but luckily you run into the wondrous and helpful data monkey, let's call him Dr. McElligott because that is a nice sounding name, and explain your problem.

The wonderful data monkey explains, ah that is easy, here is how:

SAS to STATA:

save data as a SAS XPORT file, then to import into stata use "fdause filename"

or more directly

PROC EXPORT DATA= dirname.file_to_export
OUTFILE= "C:\get_dissertation_done\filename.dta"
DBMS=STATA REPLACE;
RUN;

From STATA to SAS:
In stata use "fdasave filename" then you can import into SAS

Additionally, you can save files as csv files and import in each for

STATA: use "insheet" and "outsheet"

SAS:
proc export data = filename;
outfile = 'pathname\filename.csv';
dbms = csv;
replace;
run;

or you can use the menu driven sas export facility

"Thank you oh wonderful datamonkey, you have saved my dissertation! Let's get a beer!" you exclaim.

"I'll get you someday datamonkey" gurgles the evil Dr. Mulchay as he slouches back to his cavelike cubicle.

-The End-

2 comments:

  1. All, one addition, the SAS export facility can export directly to STATA.

    ReplyDelete
  2. PROC EXPORT DATA= dirname.file_to_export
    OUTFILE= "C:\get_dissertation_done\filename.dta"
    DBMS=STATA REPLACE;
    RUN;

    It doesn't work : I get this message "ERROR: DBMS type STATA not valid for export.".

    When I replace stat with dta I get the message.

    SAS IS REALLY A PIECE OF SHIT

    ReplyDelete