Wednesday, May 12, 2010

SAS On Demand Take 3: Success!

I am following up on two earlier posts regarding using SAS On Demand for Academics. The version of EM has been upgraded to 6.1, which means that I am now able to upload and reach non-SAS files on the SAS Server - hurray!

The process is quite cumbersome, and I do thank my SAS programming memory from a decade ago. Here's a description for those instructors who want to check it out (it took me quite a while to piece all the different parts and figure out the right code):
  1. Find the directory path for your course on the SAS server. Login into SODA ( Near the appropriate course that you registered, click on the "info" link. Scroll down to the line starting with "filename sample" and you'll find the directory path.
  2. Upload the file of interest to the SAS server via FTP. Note that you can upload txt and csv files but not xls or xlsx files. The hostname is . You will also need your username and password. Upload your file to the path that you found in #1.
  3. To read the file in SAS SODA EM, start a new project. When you click on its name (top left), you should be able to see "Project Start Code" in the left side-bar. Click on the ...
  4. Now enter the SAS code to run for this project. The following code will allow you to access your data. The trick is both to read the file and to put it into a SAS Library where you will be able to reach it for modeling. Let's assume that you uploaded the file sample.csv:
libname mylibrary '/courses/.../'; THIS IS YOUR PATH
    filename myfile '/courses/.../sample.csv'; USE THE SAME PATH
      data mydata;
        infile myfile DLM='2C0D'x firstobs=2 missover;
          input x1 x2 x3 ...;
              data mylibrary.mydata;
                set mydata;
                  The options in the infile line will make sure that a CSV file is read correctly (commas and the carriage return at the end of the line! tricky!)

                  You can replace all the names that start with "my" with your favorite names.

                  Note that only instructors can upload data to the SAS server, not students. Also, if you plan to share data with your students, you might want to set them as read only.

                  5. The last step is to create a new datasource. Choose SAS Table and find the new library that you created (called "mylibrary"). Double-click on it to see the file ("myfile") and choose it. You can now drag the new datasource to the diagram.

                  No comments: