Converting .trn data files to a Different Format

Question:
How do I convert a .trn file type into a different format like Stata, SPSS, Excel, ect. ? Example using EEOP data.

Answer 1:
There are 2 answers to this FAQ. If one does not work Please try the other one. If neither work contact ciser@cornell.edu with the .trn file you are trying to convert. It helps to also see what you have tried, what error messages are displayed.

You may copy and paste the sample codes below. The quotation marks do not paste correctly from this FAQ to SAS. You must delete and re-enter the quotation marks. SAS codes are color coded, text inside quotation marks should be purple not black.

Begin by saving the desired data table to a folder on your U drive while connected to the CISER servers. Click the following link for information regarding your U drive. Managing your Work Environment

In SAS Editor enter the following, replace italics style font with your personal locations and names:

* This denotes is a comment. Create SAS library with same path location as where I saved data table above ;
libname alias “path” ;
run;
* ‘Alias’ is nickname for ‘path’ location.;

* import data and convert into SAS dataset.;
data alias.file_name;
* data statement has 2 part name. Alias for library location. file_name is new SAS data set being created.;

filename trans “path\filename.trn”;
run;

proc cimport infile = trans lib = alias;
* the library specified in “lib=” is the library created at beginning of code.;
run;

EXAMPLE:

* data set I intend to use has been saved to the location “U:\Documents\EEOP test”;
libname tt “U:\Documents\EEOP test”; run;
* ‘tt’ is nickname for the path “U:\Documents\EEOP test”;

data tt.test1;
* below is 1 data set taken from the EEOP file. file name is ui.trn;
filename trans “U:\Documents\EEOP test\ui.trn”;
proc cimport infile = trans lib=tt;
run;

* A new file is placed at the location of my library: “U:\Documents\EEOP test”, and is in the form of a SAS stored data set;

* From this data set I can export to a different form within SAS using proc export. Example below ;
proc export data = tt.test1 outfile = “U:\Documents\EEOP test\new_file.dta”; run;
* the code above will create a new STATA data set, file extension .dta, at the location “U:\Documents\EEOP test”;

Answer 2:
If you tried the above answer and it was not successful. Please attempt to convert by following the instructions introduced in this method. Use proc copy to create a copy SAS data set from .trn file. Export data to be

In SAS Editor enter the following, replace font inside quotation marks with your own personal path location and file names:
*Referene library for file that we want to use.;
libname trans xport “U:\Documents\user files\jrg363\heg.erd8485.ed184.trn”;

*Specifies location of where new SAS dataset will be put.;
libname new “U:\Documents\user files\jrg363”;

run;

*Creates SAS dataset in location of above path specified in command line with ‘libname new’.;
proc copy in = trans out = new;
run;

*At this point make sure to check out the SAS log to see what the name of your newly created dataset is. That name is what you

*Below export my dataset to be in Stata form. Notice the ‘.dta’ extension;
proc export data = new.ed184 outfile = “U:\Documents\user files\jrg363\jrg363ts.dta”;
run;
Alternative ways to converting the SAS data set into another form is to:

  • Use the desktop application “Stat/Transfer” that can be found on any of the CISER servers.
  • Read the newly created SAS data set while another software is open. Example: The STATA command and syntax for reading in a SAS dataset is as follows:
    usesas using “path\file_name”

 
Quick Links