BookmarkSubscribeRSS Feed

Importing an Excel file into SAS Viya for Learners

Started ‎08-28-2023 by
Modified ‎08-28-2023 by
Views 5,929

Import an Excel file into SAS Viya for Learners using these steps.

 

1. Sign into SAS Viya for Learners with your SAS profile at https://vle.sas.com/vfl. The email address referenced in your SAS profile must be from an academic institution. If you have not already registered for SAS Viya for Learners, you can do so here: http://www.sas.com/viya-learners. Chrome is the preferred web browser for SAS Viya for Learners, followed by Firefox and Safari.

 

Once signed in, select the Launch button to launch SAS Viya for Learners.

 

JackieJ_SAS_1-1692979469434.png

 

2. The SAS Drive interface opens. Select the hamburger menu in the upper left:

 

JackieJ_SAS_2-1692979574288.png

 

3. Select Develop SAS Code.

 

JackieJ_SAS_3-1692979711185.png

 

The SAS Studio interface opens:

 

JackieJ_SAS_16-1692982132931.png

 

4. Select the Explorer icon in the left menu, then click the triangle icons to expand the available folders:

 

JackieJ_SAS_4-1692979948931.png

 

5. We will upload an Excel file to the Home directory. Click the Home directory folder to highlight it, then click the Upload Files button:

 

JackieJ_SAS_5-1692980078694.png

 

Note that the Courses folder is read-only, so that files cannot be uploaded to it or to its subfolders. Files can be uploaded to any other folder in the Home directory, including any new folders created by the user.

 

6. An Upload Files dialog window opens. Click the + sign to specify an Excel file to upload from your computer:

 

JackieJ_SAS_6-1692980287726.png

 

7. An application window opens. The application type and its appearance will differ by operating system. The image below illustrates using the Explorer application on a computer running a Windows operating system.

 

Navigate to the desired file, select it, then click Open.

 

JackieJ_SAS_7-1692980480987.png

 

8. The selected file, here class.xlsx, now appears in the Upload Files dialog window. Click the Upload button.

 

JackieJ_SAS_8-1692980855288.png

 

The file has been uploaded to the Home directory:

 

JackieJ_SAS_9-1692980934620.png

 

9. Excel files cannot be directly viewed in SAS Viya for Learners. To view an Excel file, the file must be downloaded back to the user's computer or imported as a SAS dataset. We will illustrate how to use the Import Utility to create a SAS dataset from an Excel file.

 

Double click on the Excel file icon, here class.xlsx. A dialog window opens. Click the Import button.

 

JackieJ_SAS_10-1692981048812.png

 

10. An import utility window opens. Keep the default choices for the Excel worksheet to import (the first worksheet) as well as for the library (WORK) and dataset name (IMPORT) of the created SAS dataset. 

Note that any worksheet in an Excel file may be imported, and datasets can be saved to any existing library, including CAS-enabled libraries.

 

JackieJ_SAS_11-1692981207451.png

 

11. Code is generated in the Code window at the bottom. Click the Run icon to run the code.

 

JackieJ_SAS_12-1692981294505.png

 

Results from the CONTENTS procedure are produced in the Results tab:

 

JackieJ_SAS_13-1692981387108.png

 

The Output Data tab provides a view of the created SAS dataset:

 

JackieJ_SAS_14-1692981447073.png

 

12. Additionally view the dataset by selecting the Libraries icon in the left menu:

 

JackieJ_SAS_15-1692981600789.png

 

The default libraries supplied in the import utility, including the WORK library, are SAS 9 libraries. If your goal is to create a SAS 9 dataset, then you are finished!

 

If you wish to use the dataset with other SAS Viya for Learners tools such as SAS Visual Analytics and SAS Model Studio, read on to the next section.

 

 

Saving an Excel file to a CAS-Enabled Library

 

SAS Viya specific tools such as SAS Visual Analytics and SAS Model Studio require the use of a CAS (Cloud Analytics Services) table instead of a familiar SAS 9 table. CAS is the application that controls the high-performance distributed computing instructions for SAS Viya.

 

The following steps show how to create a CAS-enabled library, then use the import utility to import an Excel file to a CAS table.

 

1. Click New in the upper left, then select SAS Program.

 

JackieJ_SAS_3-1692994722493.png

 

A new Program.sas tab opens:

 

JackieJ_SAS_17-1692982813392.png

 

2. Type the following code into the Program.sas tab. 

 

libname mycas cas caslib=casuser;

 

This LIBNAME statement uses the CAS engine and CASUSER caslib to create a CAS-enabled library named MYCAS. A caslib is an in-memory space whose properties are defined at the time of SAS Viya installation. The CASUSER caslib is the only personal caslib available on SAS Viya for Learners, so its name must be specified in the caslib= option. The library name MYCAS can be chosen by the user and is subject to the same naming rules as SAS 9 libraries. 

 

Click Run to execute the code.

 

JackieJ_SAS_18-1692982964942.png

 

3. Navigate back to the Libraries menu. The library MYCAS is listed.

 

JackieJ_SAS_19-1692983291153.png

 

The cloud and snowflake icon next to its name indicates the MYCAS library is a CAS-enabled library.

 

4. Repeat steps 9-12 of the previous instructions, instead specifying the library name MYCAS and dataset name MYCLASS.

 

JackieJ_SAS_9-1692980934620.png

 

JackieJ_SAS_10-1692981048812.png

 

JackieJ_SAS_0-1692996650638.png

 

JackieJ_SAS_22-1692983571995.png

 

JackieJ_SAS_24-1692983764591.png

 

5. Navigate to the Libraries menu and expand the MYCAS library. The MYCLASS table is listed.

 

JackieJ_SAS_25-1692983848912.png

 

6. We are almost done!

 

A CAS table created with the import utility has what is called session scope. This means the MYCLASS table will be deleted upon exiting SAS, and additionally means that MYCLASS is not available to SAS Viya for Learners applications outside of SAS Studio, such as SAS Visual Analytics or SAS Model Studio.

Changing the scope of MYCLASS to global scope will ensure the MYCLASS table is available in future SAS sessions as well as in other applications on SAS Viya for Learners.

 

Type the following code into the Program.sas tab, then click Run:

 

proc casutil;
promote casdata="myclass";
run;

 

The MYCLASS dataset is now promoted to global scope, so will be available in future SAS Viya for Learners sessions and in other SAS Viya applications.

 

The MYCAS library reference will be deleted upon exiting SAS, but the MYCLASS table will remain in memory. To use the MYCLASS table in a future SAS session, re-establish the MYCAS library by executing the LIBNAME statement issued in step 2:

 

libname mycas cas caslib=casuser;

 

 

 

Comments

The Viya explorer has nothing in it. We cannot upload files.

Screenshot 2024-07-31 at 2.48.26 PM.png

Version history
Last update:
‎08-28-2023 03:55 PM
Updated by:
Contributors

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags