Using Stat/Transfer on the Quarry cluster, how do I convert multiple SAS data sets into SPSS and Stata?
On the Quarry cluster, Stat/Transfer can be used to convert data from one format to another. The following commands convert a SAS data set a1.sas7bdat into an SPSS file a1.sav and a
Stata file a1.dta:
To convert multiple files to other formats, you can write a shell script and then run it. You may use nano, the default editor on
Quarry, to edit a text file(script); to edit a file named
multiples, enter at the Quarry prompt:
In the shell script file, enter the following lines:
#!/bin/bash st a1.sas7bdat a1.sav st a2.sas7bdat a2.sav st a3.sas7bdat a3.sav st a4.sas7bdat a4.sav st a5.sas7bdat a5.sav for ((i=1; i<=5; i++)) do st 'a'$i'.sas7bdat' 'a'$i'.dta' doneIn the example above, the input and output files are in the same working
directory. SAS data sets a1.sas7bdat through
a5.sas7bdat are converted into SPSS and Stata data sets
with file names a1.sav through a5.sav, and
a1.dta through a5.dta, respectively. You may
list the commands with different file names, or use a loop
(for). Press Ctrl-x and then y
to save the file and exit the nano editor.
To execute this file on Quarry, change the permission:
username@Quarry: ~> chmod 500 multiplesFinally, run the shell script file:
username@Quarry: ~> ./multiplesYou should find a1.sav through a5.sav and
a1.dta through a5.dta in the working
directory.
Note: To run Stat/Transfer without adding the full
path names, put a +StatTransfer line in the
.soft file in your home directory
For more about statistical and mathematical software, email the UITS Stat/Math Center, visit the center's web page, or phone 812-855-4724 (IUB) or 317-278-4740 (IUPUI). The center is located in Bloomington at 410 N. Park Avenue, and is open for consultation by appointment Monday-Friday 9am-5pm.
Last modified on March 30, 2011.







