Indiana University
University Information Technology Services
  
What are archived documents?
Login>>
Login

Login is for authorized groups (e.g., UITS, OVPIT, and TCC) that need access to specialized Knowledge Base documents. Otherwise, simply use the Knowledge Base without logging in.

Close

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:

username@Quarry: ~> st a1.sas7bdat a1.sav username@Quarry: ~> st a1.sas7bdat 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:

username@Quarry: ~> nano multiples

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' done

In 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 multiples

Finally, run the shell script file:

username@Quarry: ~> ./multiples

You 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.

This is document azcf in domain all.
Last modified on March 30, 2011.

Comments/Questions/Corrections

Use this form to offer suggestions, corrections, and additions to the Knowledge Base. We welcome your input!

If you are affiliated with Indiana University and would like assistance with a specific computing problem, please use the Ask a Consultant form, or contact your campus Support Center.

Contact Information

Note: We will reply to your comment at this address. If your message concerns a problem receiving email, please enter an alternate email address.