How do I convert my data files without Stat Transfer?

CISER has removed its installation of Stat Transfer software from our servers. Included below are instructions for converting data to different file formats without using Stat Transfer. Reasons for converting data to different formats include:

  • Export data to more user-friendly software for sending to fellow researchers.
  • Continue your research by further analyzing your data using a different programming language.

Instructions

Nearly all programming languages accept CSV data files. CSV stands for Comma Separated Values. CSV files can be opened and saved using excel as well as notepad for text. Making it a great file type for exporting and sharing. Below I include coding syntax, Example commands, Menu guidance and online documentation for exporting and importing CSV data for CISER’s most popular programs.

Use links below to fast travel to the software of interest.

Stata
R
Matlab
SPSS
SAS
Python
Mathematica
JMP
Minitab

Qualitative Software

Atlas.ti
NVivo

Green text indicates a comment
Console text indicates Example programming code.

Stata

Export Stata data to CSV


#Using command ‘export delimited’, Syntax:

"export delimited using ‘filename.csv’, replace"
#Example code:

Sysuse auto, clear
export delimited using "U:/Downloads/file2.csv", replace

#Using Menu:
‘File’ -> ‘Export’ -> ‘Text data (Delimited, *.csv, …)’
#Notice using the menu you can export to a variety of different formats
Stata Exporting Documentation

Import CSV data into Stata


#Using import delimited command, Syntax:

import delimited using “filename.csv”, clear
#Example code:

Import delimited using "U:/Downloads/file2.csv", clear

#Using Menu:
‘File’ -> ‘Import’ -> ‘Text data (Delimited, *csv, …)’
#Using the menu you can also import many different types of files.

Stata Importing/Exporting Documentation

R

Export R data to CSV

# Uses write.csv command. Syntax:
write.csv(data_object, ‘filename.csv’)
#Example Code

df <- data.frame(name = c("Jon", "Bill", "Maria"), age = c(23, 41, 32))
write.csv(df, 'U:/Downloads/file1.csv')

R Exporting CSV Documentation
R can export to a variety of formats. Some of the formats included in the following link.
R Exporting to other File Formats

Import csv data into R

Uses read.csv command. Syntax:
data_object = read.csv(‘filename.csv’)
#Example code

Df = read.csv('U:/Downloads/file1.csv')

Matlab

Export Matlab data to CSV

Using Writematrix or csvwrite commands. Syntax:
writematrix(object, ‘filename.csv’)
csvwrite(‘filename.csv’, object)

#Example Code

a=[234,2
671,5
735,1]


csvwrite(' U:\Downloads\file.csv',a)
Matlab exporting CSV Documentation
Matlab can export to a variety of formats other than CSV.

Import CSV Data into Matlab

Use readtable command to import delimited data. Syntax/Example Code:
T = readtable(' U:\Downloads\file.csv');
Matlab Importing CSV documentation

SPSS

Export SPSS Data to CSV

Using save translate command. Syntax/Example Code:
save translate outfile = ‘filename.csv’ /type = CSV.
save translate outfile = 'U:\Downloads\file1.csv'
/type = CSV.

Using Menu:
Activate dataset. ‘File’ -> ‘Export’ -> ‘CSV Data’
SPSS Export to CSV Documentation

Import CSV Data to SPSS

Using command GET DATA. Syntax/Example Code

GET DATA /TYPE=TXT
/FILE="U:\Downloads\file1.csv"
/DELIMITERS=","
/QUALIFIER='"'
/ARRANGEMENT=DELIMITED
/FIRSTCASE=1
/DATATYPEMIN PERCENTAGE=95.0
/VARIABLES=
V1 AUTO
V2 AUTO
/MAP.
RESTORE.
CACHE.
EXECUTE.
DATASET NAME DataSet2 WINDOW=FRONT.

#Using Menu:
Activate Data Viewer. “File” -> “Import Data” -> “CSV Data”
Importing CSV into SPSS Documentation

SAS

Export SAS data to CSV

Using Command “Proc Export”. Syntax/Code Example:

proc export data=sashelp.class outfile “U:\Downloads\class.csv" dbms=dlm replace;
delimiter = ',';
run;

Using Menu:
File -> Export Data
SAS Exporting to CSV Documentation

Import CSV Data into SAS

Using Command “Proc Import”. Syntax/Code Example:
proc import datafile="U:\Downloads\class.csv" out=Class dbms=csv replace; run;
proc print data = Class; run;

Using the menu:
“File” -> “Import Data”
SAS Import CSV Data Documentation

Python

Export Python Data to CSV

Requires csv Python library. Syntax/Code Example
Import csv
with open('eggs.csv', 'w', newline='') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=' ',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])

Python can export to a variety of files other than CSV.
Python Exporting CSV Documentation

Import CSV Data into Python

Pandas library helpful for importing and exporting csv files. Syntax/Code Example
Import pandas and pd
data = pd.read_csv("filename.csv")

Import CSV into Python Documentation

Mathematica

Export Mathematica Data to CSV

Syntax:
Export["file","Table"]
Example Code:
Export[“U:/Documents/Transfers/mathematica.csv”, Data_object]

Import CSV Data into Mathematica

Syntax:
Data_object = Import["file”]
Code Example:
Data_object = Import[“U:/Documents/Transfers/mathematica.csv”]
Mathematica Importing Exporting CSV Documentation

JMP

Exporting JMP Data to CSV

Example Code:
Current data table() << Save(“Filename.csv”, text)
Using Menu:
Activate dataset window. ‘File’ -> ‘Export’
JMP Exporting to CSV Documentation

Importing CSV Data into JMP

Example Code:
Open("dataGSS2.csv", End of Filed(comma),
Columns(
year = Numeric(4),
hh1 = numeric(1),
hh2 = numeric(2)
)
);

Using Menu:
‘File’ -> ‘Open’ -> change file types to ‘Text Files’ for importing CSV.
JMP Importing Text Files Documentation

Minitab

Exporting Minitab Data to CSV

Using Menu:
Activate Data. ‘File’ -> ‘Save Worksheet As’ -> Change ‘Save as type:’ to CSV -> Save file

Importing CSV into Minitab

Using Menu:
‘File’ -> ‘Open’ -> Change file type to be ‘Excel Files’, ‘Text’ or ‘All’. Select file you want to import and press ‘Open’.

Atlas.ti Exporting


Qualitative Software.
Export entire Atlas.ti project using Menu:
“File” -> “Export” -> “Project Bundle”
“Import & Export” tab with more exporting details.

Atlas.ti Exporting Projects Documentation

NVivo Exporting


Qualitative software.
“Share” tab from home menu has options for exporting specific files or exporting an entire project file.
#Export Specific Files within NVivo Project
Click on items in list. “Share” tab in menu -> “Export” or “Export List”
#Export Entire Project file
“Share” tab in menu -> “Copy Project”
NVivo Exporting Projects