Sas To Stata

Computing.SasToStata History

Hide minor edits - Show changes to output

March 05, 2008, at 02:50 AM by 169.229.39.192 -
Changed lines 1-4 from:
Formats (PROC FORMAT) are the most convenient way to apply value labels to categorical variable. Unfortunately, SAS does not automatically save custom formats when a data set is saved. This makes it inconvenient to STAT/TRANSFER to convert to Stata.

Here's how to save formats
:
to:
In SAS, PROC FORMAT is a convenient way to apply value labels to categorical variables. Unfortunately, SAS does not automatically save custom formats when a data set is saved. This makes it inconvenient to STAT/TRANSFER to convert to Stata.

Here's a solution
:
Changed lines 36-37 from:
STAT/TRANSFER can then use these formats when it does a conversion. My version of Stat/Transfer, automatically looks for the format file with using a particular name and directory which you can set under Options. Not the most intuitive interface, but use trial and error to get it right.
to:
If saved, STAT/TRANSFER can then use these formats when it does a conversion to another format, like Stata. My version of Stat/Transfer, automatically looks for the format file using a particular name and directory which can be set under Options. Not the most intuitive interface, but with trial and error it not too hard to figure out.
March 05, 2008, at 02:46 AM by 169.229.39.192 -
Changed line 40 from:
Tags: [[SAS]], [[Stata]], [[Stat/Transfer]], [[Hacks]]
to:
Categories: [[!SAS]], [[!Stata]], [[!StatTransfer]], [[!Hacks]]
March 05, 2008, at 02:44 AM by 169.229.39.192 -
Changed lines 38-40 from:
http://sunsite.berkeley.edu/wikis/datalab/uploads/Computing/screen1.jpg"Stat/Transfer setup"
to:
http://sunsite.berkeley.edu/wikis/datalab/uploads/Computing/screen1.jpg"Stat/Transfer setup"

Tags: [[SAS]], [[Stata]], [[Stat/Transfer]], [[Hacks]]
March 05, 2008, at 02:43 AM by 169.229.39.192 -
Changed lines 36-38 from:
STAT/TRANSFER can then use these formats when it does a conversion. My version of Stat/Transfer, automatically looks for the format file with using a particular name and directory which you can set under Options. Not the most intuitive interface, but use trial and error to get it right.
to:
STAT/TRANSFER can then use these formats when it does a conversion. My version of Stat/Transfer, automatically looks for the format file with using a particular name and directory which you can set under Options. Not the most intuitive interface, but use trial and error to get it right.

http://sunsite.berkeley.edu/wikis/datalab/uploads/Computing/screen1.jpg"Stat/Transfer setup"
March 05, 2008, at 02:39 AM by 169.229.39.192 -
Changed line 36 from:
STAT/TRANSFER can then use these formats when it does a conversion. My version of Stat/Transfer, automatically looks for the format file with using a particular name and directory which you can set under Options. Not the most intuitive interface, but use trial and error to get it right.
to:
STAT/TRANSFER can then use these formats when it does a conversion. My version of Stat/Transfer, automatically looks for the format file with using a particular name and directory which you can set under Options. Not the most intuitive interface, but use trial and error to get it right.
March 05, 2008, at 02:33 AM by 169.229.39.192 -
Changed lines 3-4 from:
Here's a solution
to:
Here's how to save formats:
Changed lines 28-36 from:
;
to:
;

To use these formats, just include the following before your DATA step:

LIBNAME hd 'd:\public\HD';
options fmtsearch=(hd);


STAT/TRANSFER can then use these formats when it does a conversion. My version of Stat/Transfer, automatically looks for the format file with using a particular name and directory which you can set under Options. Not the most intuitive interface, but use trial and error to get it right.
March 05, 2008, at 02:22 AM by 169.229.39.192 -
Added lines 1-28:
Formats (PROC FORMAT) are the most convenient way to apply value labels to categorical variable. Unfortunately, SAS does not automatically save custom formats when a data set is saved. This makes it inconvenient to STAT/TRANSFER to convert to Stata.

Here's a solution

LIBNAME hdformat 'D:\public\hd\formats';
PROC FORMAT library=hdformat;
VALUE MARCOHAB
1 ="Married, living with spouse"
2 ="Married, spouse absent"
3 ="Separated--Cohabiting"
4 ="Divorced--Cohabiting"
5 ="Widowed--Cohabiting"
6 ="Never married--Cohabiting"
7 ="Separate--Not cohabiting"
8 ="Divorced--Not cohabiting"
9 ="Widowed--Not cohabiting"
10 ="Never married--Not cohabiting"
;
VALUE MB2F
1 ="Married"
2 ="Separated, because of marital problems"
3 ="Divorced"
4 ="Widowed"
5 ="Never married"
7 ="Refused"
9 ="Inap/no answer"
99 ="Unknown"
;